Discussion Thread: DIP 1043--Shortened Method Syntax--Community Review Round 1
Adam D Ruppe
destructionator at gmail.com
Wed Feb 9 13:05:35 UTC 2022
On Wednesday, 9 February 2022 at 12:38:56 UTC, bauss wrote:
> void a() => b(); is valid in __all__ other languages that
You can do that in D too, as long as b also returns void.
BTW it'd actually be a fairly simple change to the dip to allow
these things. Instead of
`x => y` translated to `x { return y; }`
it could be translated to `x { return cast(typeof(return))( y );
}`
But casts are kinda harmful so i don't think that's a good idea
in general. Of course it could special case it and say it does:
`x { static if(is(typeof(return) == void)) return cast(void) (y);
else return y; }`
but idk.
More information about the Digitalmars-d
mailing list