proposal: short => rewrite for function declarations

Timon Gehr timon.gehr at gmx.ch
Sun Oct 11 16:04:45 UTC 2020


On 11.10.20 17:43, Adam D. Ruppe wrote:
> On Sunday, 11 October 2020 at 15:38:26 UTC, Timon Gehr wrote:
>> Why add incidental complexity like this all?
> 
> That's why I kept the two commits separate. I'm not in love with it 
> either but if it is what people want,

My point was that nobody should want that.

alias bar0=(v)=>v;
void foo0(v)=>v; // why special-case this,

alias bar1=(v){ return v; }
void foo1(v){ return v; } // but not this?

void baz0(int){ return 2; } // why is this fine,
void baz1(int)=>2;          // but this is not?

alias baz2=(int)=>2;        // and this is allowed!

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.

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

> it was simple enough to implement 
> too. Or just skip that commit.

+1.


More information about the Digitalmars-d mailing list