[erlang-questions] A modest proposal to eliminate tuples

Chris Pacejo <>
Wed Aug 27 20:21:32 CEST 2014

Tuples are clearly unnecessary and a wart in Erlang's design.
Consider all the operations tuples provide:

Construction: X = {A,B,C}
Destruction: {A,B,C} = X
Pattern matching: case X of {foo,B,C} -> ... end

Note now that these operations are provided equally by lists:

Construction: X = [A,B,C]
Destruction: [A,B,C] = X
Pattern matching: case X of [foo,B,C] -> ... end

And note that lists provide the additional functionality of indexing
and consing, which tuples do not provide.

Clearly, using tuples instead of lists provides no benefit, and to
simplify the language they should be deprecated in OTP 18, and removed
by OTP 19.  To support this transition, a compiler option can be
provided to maintain the ill-conceived tuple notation for legacy code;
may I suggest +distinguish_homogenous_and_heterogenous_collections.

Now, surely detractors will claim that the distinction between tuples
and lists signals programmer intent, permits bytecode optimization,
and enables rich typechecking in Dialyzer.  I claim these purported
benefits are bollocks.  I, and no doubt others, routinely find the
need to iterate over tuple elements, and to store unrelated data
together in a single list.  Anyone who claims that such things are not
necessary clearly has not ever written a complex program.  (I suspect
anyone who thinks structurally-typed records and key-value maps serve
different purposes falls into this group.)

I hope you all agree, and that we can look forward to a future Erlang
supporting lists and maps as its sole data constructors.

- Chris P

More information about the erlang-questions mailing list