[erlang-questions] A modest proposal to eliminate tuples

Erik Søe Sørensen eriksoe@REDACTED
Wed Aug 27 22:12:42 CEST 2014


No - down with lists. Tuples for everything! More specifically, 2-tuples
only! (But we get to keep nil. Can't do without nil.)

Joke aside, thanks for the calendrical confusion.
Den 27/08/2014 20.51 skrev "Dmitry Demeshchuk" <demeshchuk@REDACTED>:

> 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 <colanderman@REDACTED>
> 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
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>
>
>
> --
> Best regards,
> Dmitry Demeshchuk
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140827/6a7a4279/attachment.htm>


More information about the erlang-questions mailing list