C++11 lambdas

Paul Benedict pbenedict at apache.org
Sun Mar 14 12:35:33 PDT 2010


I wholly agree with Remi. The current lamda discussions have created
virtually unreadable syntax -- I practically felt buried by the parade
of syntax tokens! Going back to simple types that look like C function
pointers is so much better than what is being discussed now. I think
"the wrong direction" was aptly put.

On Sun, Mar 14, 2010 at 11:14 AM, Rémi Forax <forax at univ-mlv.fr> wrote:
> Le 14/03/2010 15:31, Neal Gafter a écrit :
>> On Sun, Mar 14, 2010 at 5:21 AM, Stephen Colebourne<scolebourne at joda.org>wrote:
> Yes, seeing that I wonder if we are not going in the wrong direction by
> trying
> to protect lambda and function type by a # or some enclosing parens.
>
> Why not trying something simpler ?
>
>
> A function that takes an int and returns an int:
> int(int)
>
> A function that takes an int and returns nothing:
> void(int)
>
> A function that takes two ints and returns an int:
> int(int, int)
>
> A function that throws an Exception:
> int(int) throws Exception
>
> A function that takes a function that throws an Exception:
> int(int(int) throws Exception)
>
> A function that throws an Exception and takes a function
> int(int(int)) throws Exception
>
> A function that takes an int and returns a function that returns an int
> int() (int)
>
> curry!
> R() throws E (R(A) throws E, A) curry = ...
>
> Grammar:
> ResultType ( TypeList ) throws ExceptionList
>
>
> And removing the # in the lambda syntax:
>
> int(int) fun = (int x) (x);  // lambda expression
> int(int) fun = (int x) { return x; };  // lambda block
>
> A method that returns a lambda:
> int(int,int) plus() {
>   return (int x, int y) (x+y);
> }
>
> A method that takes two function types and returns a lambda:
> int(int,int) filter(int(int) filter, int(int,int) operation) {
>   return (int x, int y) {
>     return operation.(filter.(x), filter.(y));
>   };
> }


More information about the lambda-dev mailing list