Anonymous function syntax

Jonathan M Davis jmdavisProg at gmx.com
Sat Sep 24 00:22:27 PDT 2011


On Saturday, September 24, 2011 07:14:13 John Chapman wrote:
> == Quote from Jonathan M Davis (jmdavisProg at gmx.com)'s article
> 
> > On Friday, September 23, 2011 23:42:52 Andrei Alexandrescu wrote:
> > > On 9/23/11 8:03 PM, Martin Nowak wrote:
> > > > On Thu, 22 Sep 2011 22:54:55 +0200, Andrei Alexandrescu
> > > > <SeeWebsiteForEmail at erdani.org> wrote:
> > > > I want to add some points against introducing this particular
> > > > syntax.
> > > > 
> > > > 1. Foremost using '=>' is unfamiliar. Comming from C++ or Java
> > > > you
> > > > really have to learn reading it.
> > > > If you weighted the lambda syntaxes with the tiobe factor,
> > > > arrows would be a minority.
> > > 
> > > Well the C++2011 lambda syntax is quite foreign for C++ users, too.
> > 
> > And Andrei's suggested syntax is very similar to C#'s lambda syntax, so
> > it _is_ a syntax familiar to some of the programmers who use a major
> > language derived from C++. It's certainly going to be more familiar
> > than the syntax of any of the functional languages out there.
> 
> Java's adopting the C# syntax for its lambdas too.
> http://java.dzone.com/news/java-8-lambda-syntax-decided
> 
> And is it that hard to learn?

I definitely agree with the reasoning given in the article:

"Despite extensive searching, there was no clear winner among the 
alternatives (each form had some good aspects and some really not very 
good aspects, and there was no form that was clearly better than the 
others).  So, we felt that it was better to choose something that has 
already been shown to work well in the two languages that are most like 
Java -- C# and Scala -- rather than to invent something new."

It's pretty much my thoughts exactly. So, unless there's something objectively 
wrong with this syntax which would make it a bad choice for D, I think that we 
should adopt some version of it. When 2 of the other major C++-derived 
languages choose a syntax which also works for D, it just seems like a good 
idea to follow suit.

- Jonathan M Davis



More information about the Digitalmars-d mailing list