Array literals' default type

Don nospam at nospam.com
Mon Oct 12 07:47:34 PDT 2009


grauzone wrote:
> Don wrote:
>> Not so, Andrei has said that he thinks auto-flattening was a bad idea. 
>> And AFAIK, Walter doesn't disagree.
> 
> You should try harder, because if you don't change it soon, it will be 
> there forever due to compatibility requirements.

The TODO list is very long.

>> Andrei and I, and almost everyone else, have tried to persuade Walter 
>> to remove the comma operator, but without success. But I doubt you'd 
>> be able to use it for tuples, because   x, y = foo(); already has 
>> meaning in C and tuples would give it a different meaning. I'd LOVE to 
>> be proved wrong.
> 
> Wasn't the comma operator to be supposed to be important for automatic 
> code generation?

It's used frequently in in the compiler internals. EG, given

int foo(X x = default_value) { return 0; }
then foo(); becomes:   (X tmp = default_value, foo(tmp));

I don't think it sees much use outside of compilers. There are other 
ways to get the same effect in user code.

> Even if it is, you could just pick a different token to implement this 
> operator. It doesn't have to be a comma, does it?

It doesn't need any syntax at all, when it's inside the compiler.
But the problem is, that comma has that meaning in C.

(OTOH I wonder how much extant C++ code uses the comma operator. I bet 
there's not much of it. (But more than code than uses octal!)).


BTW as an asm programmer, I'm completely baffled as to why the concept 
of 'single return value from a function' became dominant in programming 
languages. It's a very unnatural restriction from a machine point of view.



More information about the Digitalmars-d mailing list