[erlang-questions] Wrong advertised spec of lists:append/2

Masklinn masklinn@REDACTED
Thu Mar 28 15:06:46 CET 2013

On 2013-03-28, at 14:50 , Karolis Petrauskas wrote:

> Indeed, what does the 2'nd line mean?
> 1: 16> [a, b] ++ c.
> 2: [a,b|c]
> 3: 17> c ++ [a, b].
> 4: ** exception error: bad argument
> 5:      in operator  ++/2
> 6:         called as c ++ [a,b]

That it's an "improper list" (also known as "dotted pairs" in lisps):
lists are sequences of (head, tail) pairs where "tail" is a pointer to
the next pair, and in a proper list the final tail is always a "null".
Here the "tail" is a pointer to a symbol, which creates an improper
list. Many functions will blow up when given this, because they won't
handle the terminal case of a non-list.

More information about the erlang-questions mailing list