[erlang-questions] Dialyzer and improper lists

Kostis Sagonas kostis@REDACTED
Fri Dec 28 01:20:05 CET 2012


On 12/27/2012 01:28 AM, Aliaksey Kandratsenka wrote:
> Hi.
>
> It appears dialyzer complains loudly about any code that builds improper
> lists. And there appears to be no local way to silence that warning.

Dialyzer is an optional tool (nobody forces you to use it if you do not 
find it useful) and identifies code discrepancies (Dialyzer stands for 
`Discrepancy Analyzer for Erlang') for which it issues warnings. Nobody 
ever claimed that all these are discrepancies are bugs; instead, they 
are code points where a programmer action is arguably needed. Whether 
issuing a warning classifies as "complaining loudly" is a matter of 
definition.

Your second sentence is true. Dialyzer has no local ways of silencing 
warnings but it does come with options (-Wno_improper_lists in this 
case) to silence specific categories of warnings that are on by default 
and also enable other categories of warnings (e.g. -Wunmatched_returns) 
which are off by default.

> It's true that sometimes it's a sign of bug. But on the other hand
> dialyzer docs saying there's no reason to use improper lists (even in
> ALL CAPS) is clearly wrong. According to my understanding improper list
> of size 2 needs just 2 words (single cons pair and no headers), but
> binary tuple needs one extra word for header.

Right. And do you have an application where you have experienced that 
this makes any considerable difference? If so, I would like to see it. 
More importantly, if you do have such an application, are you _really_ 
sure that Erlang is the most appropriate language for programming it?

> And erlang's stdlib has a bunch of places where cons pair is used as a
> binary tuple. E.g. dict.
>
> While docs should not necessarily point folks to low-level tricks like
> that, they IMHO should be fixed to reflect reality.
>
> But IMHO most importantly, there should be some way to say to dialyzer
> "hey I really mean improper list here" without disabling improper list
> check completely.

If you find such a feature useful, feel free to submit an appropriate 
patch and we may consider including it in dialyzer's code base. Please 
make sure to make this `local silencing of warnings' feature pretty 
robust under code changes. It's obviously not rocket science to design 
and implement such a scheme, but I am warning you that it's also not a 
trivial task.

Kostis



More information about the erlang-questions mailing list