lua-users home
lua-l archive

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


2012/6/17 Egor Skriptunoff <egor.skriptunoff@gmail.com>:

>
> Does these anonymous functions forced to return some expression as result?
>
In Pari/GP, the result of the most recent calculation before returning
is automatically the return value.  If there was no calculation, 0 is returned.
(In many ways, 0 in Pari/GP does the job of nil in Lua.)

> What about other simple functions?
>
> add=(delta)->x=x+delta
>
In Pari/GP, you don't use the parentheses.

add=delta->x=x+delta

That's perfectly legal in Pari/GP.  It increments x and returns the
incremented value.

> Assignment is not an expression in Lua.
> Should this definition cause compilation error?

As I said, I'm not suggesting this syntax for Lua — but if
someone does suggest it, I would definitely oppose allowing
side effects.