proposal: short => rewrite for function declarations

Imperatorn johan_forsberg_86 at hotmail.com
Sat Oct 10 13:55:13 UTC 2020


On Saturday, 10 October 2020 at 13:05:48 UTC, Mike Parker wrote:
> On Saturday, 10 October 2020 at 12:30:24 UTC, Imperatorn wrote:
>
>>>
>>> @property x() => _x;
>>>
>>> vs
>>>
>>> @property x() { return -x; }
>>>
>>> cause the important thing to me is that my code is simple, 
>>> readable, expressive, i dont care about saving 7 chars on a 
>>> one liner.
>>
>> What do you mean. It removes stuff. I'd say Adam's proposal is 
>> more readable.
>
> Not to me. Taking away the braces and the return statement 
> turns it into a foreign language.

Might be a bit of a stretch to say it becomes a "foreign 
language" just because you change one thing... But, I do agree 
that in general you should be very restrictive about adding 
things. A new feature always seems so nice and shiny in the 
beginning, before you have analysed its potential side effects.


More information about the Digitalmars-d mailing list