proposal: short => rewrite for function declarations

Timon Gehr timon.gehr at gmx.ch
Sun Oct 11 18:59:28 UTC 2020


On 11.10.20 20:48, Steven Schveighoffer wrote:
> 
>> The complaint is _orthogonal_ to what's being discussed.
>> This would add another special case just for the sake of making the 
>> language specification a bit longer.
> 
> To prevent confusion and inconsistency.
> ...

This specifically adds more inconsistency. It does nothing useful on top 
of that, as our examples have demonstrated.

> these two are equivalent "function-like" things:
> 
> alias x= (T t) => expr;
> auto x(T t) { return expr;}
> 

alias x=(T t){ return expr; }
auto x(T t){ return expr; }

> These two are not:
> 
> alias x = (t) => expr; // t is a parameter
> auto x(t) => expr; // t is a type
> ...

alias x=(t){ return expr; }
auto x(t){ return expr; }

Not sure what you are trying to achieve by varying the syntax this way. 
`=>` or not `=>` has nothing to do with function literal semantics.

>> (args)=>e is a shorthand for (args){ return e; } and this is a simple, 
>> consistent rule. What happens later in semantic is not the business of 
>> the parser.
> 
> I don't think it needs to be a parser error.

The rewrite is performed in the parser.


More information about the Digitalmars-d mailing list