proposal: short => rewrite for function declarations

Q. Schroll qs.il.paperinik at gmail.com
Sun Oct 18 03:03:32 UTC 2020


On Saturday, 10 October 2020 at 10:18:15 UTC, claptrap wrote:
> From the recent discussions I got the impression that needless 
> syntax sugar shouldn't be added any more.

together

> cause the important thing to me is that my code is simple, 
> readable, expressive

Maybe it's nothing for you, but to me, your second paragraph is 
exactly the refutation for the first.
It's also about coherence. When lambdas are used, the syntax x => 
expr is used everywhere when it is admissible, proving their 
worth.

I do write things like
     int foo(Type param) { return goo(param); }
but only because
     int foo(Type param) => goo(param);
is not admissible.
     int foo(Type param) { return goo(param); }
is not D-style, but
     int foo(Type param)
     {
         return goo(param);
     }
is. Have three of them and they waste significant horizontal 
space in the source buffer. Every layer of brackets (any kind) in 
a line adds confusion and hinders our commonly beloved 
readability. Haskell has weird stuff like the $ operator to deal 
with Lisp-esque amounts of brackets.


More information about the Digitalmars-d mailing list