Should the comma operator be removed in D2?

Ellery Newcomer ellery-newcomer at utulsa.edu
Tue Nov 17 16:08:56 PST 2009


Yigal Chripun wrote:
> KennyTM~ wrote:
>> On Nov 18, 09 05:40, Ellery Newcomer wrote:
>>> Bill Baxter wrote:
>>>>
>>>> However, I think for the good of humanity we can accept that one
>>>> little bizarre example of legal C syntax not doing the same thing in
>>>> D.
>>>
>>> int[] i;
>>>
>>> auto a = (i)[0];
>>>
>>> what does this do?
>>
>> (i) should not construct a tuple. Probably (i,).
> 
> I agree, a tuple of one element (doesn't matter what type, array in this
> case) should be semantically identical to that single element.
> 
> proper semantics for language supported tuples should IMO include:
> 1) syntax to explicitly [de]construct tuples and no auto-flattening
> 2) a tuple of one element is identical to a scalar:
>    int a = 5; // scalar integer
>    auto b = (5); // tuple of one integer
>    a == b // is true
> 3) function's argument list is a tuple like in ML:
>    void foo(int a, char b);
>    int a = 5; char b ='a';
>    auto tup = (5, 'a');
>    foo(a, b) is identical to foo(t);

does ML have any equivalent of template parameters? eg

foo!(1,int);

> 4) unit type defined by the empty tuple instead of c-like void



More information about the Digitalmars-d mailing list