[erlang-questions] specs for fixed length lists

Anthony Ramine n.oxyde@REDACTED
Sun Jul 8 20:14:34 CEST 2012


Doesn't this spec mean "a list of atom() or list of integer() and empty list"? I don't see any nonempty constraint in this type.

Regards,

--
Anthony Ramine

Le 7 juil. 2012 à 21:53, Richard Carlsson <carlsson.richard@REDACTED> a écrit :

> On 2012-07-07 13:57, Tony Rogvall wrote:
>> Try this:
>> 
>>     -type buttons() :: [boolean() | [boolean() | [boolean() |
>> [boolean() | []]]]].
> 
> You certainly can _write_ it like that, just like you can write "1+1" instead of "2". To a tool like Dialyzer, it will still just be interpreted as a (nonempty) list of boolean(). The exact number of elements is not tracked. And if you for example try to say "[atom() | [integer() | []]]", it will just be the same as saying "nonempty list of atom()|integer()" - the order of occurrence of the element types is also not part of the list type.
> 
>    /Richard
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list