Discussion Thread: DIP 1043--Shortened Method Syntax--Community Review Round 1

Tejas notrealemail at gmail.com
Sun Feb 6 01:53:15 UTC 2022


On Saturday, 5 February 2022 at 22:42:35 UTC, IGotD- wrote:
> On Friday, 4 February 2022 at 10:53:45 UTC, Mike Parker wrote:
>> ## Discussion Thread
>>
>> This is the discussion thread for the first round of Community
>> Review of DIP 1043, "Shortened Method Syntax":
>>
>> https://github.com/dlang/DIPs/blob/5a3b437f2b6be8fb23e855fc0da20f19f68edac8/DIPs/DIP1043.md
>
> Just to ensure, the new simplified method syntax is only for 
> single assignment methods, right?
>
> I haven't detail studied the AssigmentStatement grammar but is 
> there any possibility that the new syntax can be abused? For 
> example starting new entire statement blocks and that way 
> creating a new ugly way of writing methods.
>
> The reason not allowing the lamda syntax was to have a single 
> way of writing methods. If we allow the new syntax, the we need 
> restrictions for that one as well so that it doesn't become a 
> Frankenstein.

I guess you can abuse it like
```d
auto func(int a, int b) => (a,b)
{
     int c,d;
     return a+b+c+d;
}(a, b);
```
Basically you can write a regular function body if you enclose it 
inside a lamba and call it immediately.


More information about the Digitalmars-d mailing list