proposal: short => rewrite for function declarations
Adam D. Ruppe
destructionator at gmail.com
Fri Oct 9 19:52:11 UTC 2020
On Friday, 9 October 2020 at 19:11:44 UTC, Steven Schveighoffer
wrote:
> You aren't saving much though, I do a lot of one-liners like:
Yeah, but we could (and did) say the same thing about the other
uses of the => syntax. It was accepted there, so this just makes
it consistently allowed in more cases.
> Which is super-useful and less verbose. But in this syntax, I'm
> guessing it's going to interpret v as a type?
Right, it will complain "undefined identifier", same as if you
wrote it `whatever foo(v) { return stuff; }`. As you can see from
the PR diff, there's no special cases, just a straight forward
syntax shortcut to keep it simple.
Of course you can still do:
auto identity(T)(T a) => a;
if you wanted to.
More information about the Digitalmars-d
mailing list