Lambda syntax, etc
Jarrett Billingsley
jarrett.billingsley at gmail.com
Mon Feb 9 05:53:18 PST 2009
On Mon, Feb 9, 2009 at 3:19 AM, Bartosz Milewski <bartosz at relisoft.com> wrote:
> 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);
Far too noisy.
auto r = find!(\a -> a.Weight > 100)(range);
Of course I _may_ be a bit biased in this regard, considering this is
the syntax MiniD uses ;)
And of course, for multi-statement lambdas:
something(\a, b
{
stmt1;
stmt2;
});
More information about the Digitalmars-d
mailing list