[erlang-patches] Add a proplist() type
Richard Carlsson
carlsson.richard@REDACTED
Tue May 24 10:38:30 CEST 2011
On 05/23/2011 09:37 PM, Ryan Zezeski wrote:
> Richard, I think specifying it as [property()] makes more sense because
> [any()] is just a list, and at that point why are you using a proplist?
The main use of the proplists module is to allow humans to specify a
list of options to a function, in a readable way. The idea, when I wrote
it, was that if a program wants to allow other things in its option list
- for example, a naked integer might make sense in some cases - it
should still be able to use the proplists module for most of its normal
options, so the proplists functions should not crash on unexpected
elements. As long as this is allowed, Dialyzer should not complain about
arbitrary lists as input.
On the other hand, if you constrain the input type to [property()], it's
fairly simple to work around the Dialyzer warning by doing an initial
pass over the list and convert the naked values to valid properties,
e.g., mapping integers to {some_tag, N}, before you pass the list to the
proplists module.
> Said another way, if the type was [any()] then I don't really see much
> of a benefit of typing it at all.
Knowing that it must be a (proper) list is obviously better than not
knowing anything at all.
/Richard
More information about the erlang-patches
mailing list