Lambda syntax, etc
Bartosz Milewski
bartosz at relisoft.com
Mon Feb 9 00:19:05 PST 2009
bearophile Wrote:
> Now, back to the topic: putting arguments into a single () or {} instead of a (){ return ;} (or with the => of C#) helps the eye see a single visual object isntead of two, this helps the human parsing of the code, improving visual chunking and reducing noise.
I also believe that, for readability reasons, lambdas should have some distinct token(s) in the beginning. C++ starts lambdas with brackets, []; C# has the distinct =>. I like the Haskell syntax that uses a backslash, which looks very much like lambda. Here's an example of such syntax:
auto r = find!( \(a) { return a.Weight > 100; })(range);
It goes without saying that any decent D editor would display the backslash as a Greek lambda.
More information about the Digitalmars-d
mailing list