[erlang-questions] A modest proposal to eliminate tuples

Paul W <>
Wed Aug 27 20:54:41 CEST 2014


Hey, it works for PHP!

On Wed, Aug 27, 2014 at 2:51 PM, Dmitry Demeshchuk <>
wrote:

> I, personally, think lists are obsolete too. Instead, everyone should just
> use maps for everything:
>
> { 1 => first_element, 2 => second_element, 3 => third_element }.
>
>
> On Wed, Aug 27, 2014 at 11:21 AM, Chris Pacejo <>
> wrote:
>
>> 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
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>
>
>
> --
> Best regards,
> Dmitry Demeshchuk
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
>


-- 
Paul Woolcock
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140827/e4afe8a2/attachment.html>


More information about the erlang-questions mailing list