Anonymous function syntax

pillsy pillsbury at gmail.com
Thu Sep 22 08:42:57 PDT 2011


== Quote from Andrei Alexandrescu (SeeWebsiteForEmail at erdani.org)'s article
> On 9/22/11 1:47 AM, Max Klyga wrote:
> > Actually Scala doesn't need type declarations in labmda literals. Most
> > of the time argument types are infered.

> Already does. We're looking for a briefer syntax.

What is the problem with just inferring the `return`, allowing you to replace

     (a,b) { return a + b; }

with

    (a, b) { a + b; }

This seems competitive with the other syntaxes for brevity, but ISTR there was some objection to doing things that
way.

Also would it make sense to have a template library along the lines of boost::proto/boost::lambda to allow even
shorter, expression-based lambdas like

    _1 + _2

I'm not exactly a D template metaprogramming pro, but I think this would work for a lot of common cases.

Cheers, Pillsy


More information about the Digitalmars-d mailing list