Array literals' default type

Yigal Chripun yigal100 at gmail.com
Mon Oct 12 14:27:48 PDT 2009


On 12/10/2009 23:00, Yigal Chripun wrote:
> On 12/10/2009 15:43, Don wrote:
>> language_fan wrote:
>>> Sat, 10 Oct 2009 17:15:55 +0200, Yigal Chripun thusly wrote:
>>>
>>>> Now, wouldn't it be wonderful if D had provided real tuple support
>>>> without all the Tuple!() nonsense?
>>>
>>> 'D has full built-in tuple support' has been the answer each time I've
>>> asked. It seems not to be advisable to ask more about this specific
>>> feature since the language creators easily get annoyed when asked
>>> about this. They see more value in reserving the syntax for the C
>>> style sequencing operator which is rarely used. Also they have
>>> apparently scientifically proven that the auto-flattening semantics of
>>> tuples somehow works better than real product types, and have no
>>> intention to make it an explicit controllable operation, which is also
>>> easily implementable.
>>
>> Not so, Andrei has said that he thinks auto-flattening was a bad idea.
>> And AFAIK, Walter doesn't disagree.
>>
>> 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.
>>
>> It is very difficult to change Walter's mind about many things, but
>> despite what people say, it is not impossible.
>
> what's wrong with enclosing tuples in parenthesis?
> (x, y) = foo();
>
> int foo();
> int bar();
>
> int a = foo(), bar(); // sequence
> int b, c;
> (b, c) = (foo(), bar()); // tuples
> b, c = foo(), bar(); // sequence
> (b, c) = foo(), bar(); // error assigning int to (int, int)
> b, c = (foo(), bar()); // error assigning (int, int) to int
>
>

one more note:

there's no need to special case the for loop.

for (int i = 0, j = 0; someCondition; i++, j--) {...}
                                       ~~~^~~~~
the above will continue to work whether it's a tuple or a C sequence.






More information about the Digitalmars-d mailing list