On 9/22/11 10:42 AM, pillsy wrote:
== Quote from Andrei Alexandrescu (seewebsiteforem...@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.

The objection is that it introduces a number of questions:

1. How about using that syntax in regular functions?

2. What if the lambda wants to actually evaluate the expression but return void?

3. How is the semicolon relevant? (If its presence is used as a disambiguator for (2), it's poor design to predicate a large semantic difference on such a distinction.)

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.

Such an approach has caused more trouble than benefits in C++.


Andrei

Reply via email to