Should the comma operator be removed in D2?

Leandro Lucarella llucax at gmail.com
Tue Nov 17 11:12:55 PST 2009


Leandro Lucarella, el 17 de noviembre a las 16:05 me escribiste:
> Ellery Newcomer, el 17 de noviembre a las 12:58 me escribiste:
> > >>> Code ported from C should not compile if the comma expression is
> > >>> converted
> > >>> to a tuple literal because if a and b are int, typeof(a,b) is int now
> > >>> and
> > >>> will be Tuple!(int, int) in the future, and I don't think
> > >>> a Tuple!(anything) could be implicitly casted to anything, except,
> > >>> maybe,
> > >>> another tuple, but you don't have tuples in C, so there is no risk on
> > >>> that.
> > >>>
> > >>
> > >> void fun1(int a);
> > >> void fun1(Tuple!(int,int) a);
> > >>
> > >> fun1( (a=fizbang(), a+b) );
> > > 
> > > These are not code ported from *C*.
> > 
> > all but the second fun1 are, and it could easily exist in D
> 
> We agree except for the *easily*. On the contrary, I think it would be
> extremely rare.

And BTW, you introduced a new overload, the same could happen with any
type:

void fun1(int a);
void fun1(double a);

int a;
double b;
fun1( (a=fizbang(), a+b) );

now fun1(double) gets called, and you introduced a bug in the current
state of D. So even when this (very rare) problem could exists, it's not
introducing by changing the comma operator to be a tuple literal.

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
Y2K
- what a disappointment... i had at least expected one nuclear plant to blow



More information about the Digitalmars-d mailing list