DIP19: Remove comma operator from D and provision better syntactic support for tuples

Timon Gehr timon.gehr at gmx.ch
Mon Sep 24 16:29:48 PDT 2012


On 09/25/2012 12:28 AM, bearophile wrote:
> Timon Gehr:
>
>>> My bikeshed is colored one of these:
>>>
>>> (:1,2)
>>> (|1,2)
>>>
>>
>> At that point you might as well just use
>>
>> import std.typecons : q = tuple, Q = Tuple;
>>
>> Q!(int, int) foo(){
>>     return q(1, 2);
>> }
>>
>> If built-in tuples are not going to look like
>>
>> (1, 2)
>>
>> then imho we might as well leave them out,
>
> But the banana syntax doesn't look bad:
>
> (||)
> (|1|)
> (|1, 2|)
> (|1, 2, 3|)
>
> It's short enough,

It's not shorter than q()

> it's not visually noisy,

It adds more noise than q()

> it's simple enough to type,

It is harder to type than q().

> it consistently avoids the problems with literals for
> 0-tuples and 1-tuples, and it's sufficiently intuitive once you
> have seen it one time.  It's just a bit longer to type than the
> syntax with simple (), that has problems with the shorter tuples.
>

I still think any built-in special syntax that differs from (1,2,3) is
not worth it.

> The now dead Fortress language used several similar syntaxes,
> like (|...|), {|...|}, [|...|], etc.
>





More information about the Digitalmars-d mailing list