"for" statement issue
    Nick Treleaven via Digitalmars-d 
    digitalmars-d at puremagic.com
       
    Sat Oct 22 08:53:47 PDT 2016
    
    
  
On Friday, 21 October 2016 at 15:26:12 UTC, mogu wrote:
> [1,2,3].fold!((a, b) => a + b).writeln;
>
> =>
>
> [1,2,3].fold!{a, b => a + b}.writeln;
Probably (a, b => a + b) could be legal. Reasoning:
1. a could be an existing symbol in scope, otherwise it's an 
undefined identifier error.
2. If a was interpreted as an existing symbol which is followed 
by the comma operator, the expression (a) wouldn't have side 
effects so should be a compile error.
3. The bracketed comma expression would have to return the lambda 
b=>a+b as a value expression, which cannot compile because there 
are no arguments supplied for calling the lambda to obtain a 
value.
So this syntax seems available as it isn't currently used for 
working code. A small change, maybe, but it's good to reduce 
bracket nesting to help with reading complex nested expressions.
Destroy.
    
    
More information about the Digitalmars-d
mailing list