[erlang-questions] A modest proposal to eliminate tuples

Anthony Ramine n.oxyde@REDACTED
Wed Aug 27 20:34:20 CEST 2014


Are we 1st April already? I didn’t implement yet my patch to make tuples 0-indexed. :(

But well, that is overseded by your proposal.

-- 
Anthony Ramine

Le 27 août 2014 à 20:21, Chris Pacejo <colanderman@REDACTED> a écrit :

> 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
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list