lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Thu, Nov 25, 2010 at 9:34 PM, Axel Kittenberger <> wrote:
> Why everything so complicated?
> How about simply this
> lambda(x) x == 2
> no end, no return, no statements before return, if you want statements
> use function() syntax. The lambda goes until end of statement, if you
> want to write more in the line use a ';' to separate it like other
> statements. A lambda function is also by itself terminated by a ','.
> If you need something like 'if', use something like 'select' when in
> function-coding-style-mode.
> return lambda() x, y   ==is==> return function() return x end, y
> if you want to return multiple value, use brackets:
> return lambda()(x, y)  ==is==> return function() return x, y end

What if your lambda contains a single function call in parentheses, like this:

  lambda(a) (myfunc(100, a))

Say myfunc() returns 3 values. Should they get truncated to 1 value by
the lambda? Parentheses around a function call will ordinarily
truncate it to one value - but that is confusingly at-odds with having
optional parentheses around lambda return values.

Simplicity is not so easily achieved :)