Array literals' default type

Ellery Newcomer ellery-newcomer at utulsa.edu
Mon Oct 12 17:20:00 PDT 2009


Yigal Chripun wrote:
>>
>> what's wrong with enclosing tuples in parenthesis?
>> (x, y) = foo();

I'm guessing you'd end up with some weird rules

z = foo(); // what is z, a tuple, or y?

auto (a,b) = ((1,2),(3,4)); // eh, what is this?

foo((1,2)); // um, what?

When offered semantic ambiguity, just say no.

>>
>> 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.
> 
> 
> 

How about this?

OtherTypeIwant foo(out bool flag){...}

...

while(guardflag && (x=foo(f), f)){
...
}


Just checked, still have something like this in my code.



More information about the Digitalmars-d mailing list