Improper lists [was: Dialyzer v1.3.0 released]

James Hague james.hague@REDACTED
Tue Mar 29 16:27:29 CEST 2005


Matthias Lang wrote:
> 
> It's possible to see it the other way around. Cons cells are
> universal.

True.  But the way I see it, the fundamental difference is that lists
are designed to contain an arbitrary number of values, whereas tuples
contain a fixed number.  If I see {10, 3}, then I know that those are
a pair of values with some meaning.  If I see [10, 3], however, then I
don't know if that's a pair or two separate values or what.  Tuples
make data be atomic.

Separating the two also makes output unambiguous:

{1,2} displays as {1,2}
[1|2] displays as [1|2]

but

{1,[2,3]} displays as {1,[2,3]}
[1|[2,3]] displays as [1,2,3]

James



More information about the erlang-questions mailing list