lua-users home
lua-l archive

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


2009/12/3 David Kastrup <dak@gnu.org>:
> And it can't even sensibly deal with multiple return values.
>
> local x=3
> fun2(|x| x*x,x)
>
> Is this
> fun2(function(x) return x*x end, x)
> or
> fun2(function(x) return x*x, x end)
> ?

I think you didn't understood the point. The notation

|<args>| <expr>

in meant to replace

function(<args>) return <expr> end

only in the case we have an expression and returned value. As you
should know, in Lua, a comma separated list of expression is *not* an
expression so there is no ambiguity whatsoever.

I repeat it:
- the comma ',' is *not* an operator in Lua
- a comma separated list of expression is *not* an expression

so there is no ambiguity. If you want to return multiple values you
should use the ordinary notation.

Francesco