[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Pari/GP has introduced lightweight anonymous function syntax
- From: Dirk Laurie <dirk.laurie@...>
- Date: Sun, 17 Jun 2012 16:44:06 +0200
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.