[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [proposal] A statement that can return value (and can used in expr)
- From: David Manura <dm.lua@...>
- Date: Tue, 13 Dec 2011 23:03:12 -0500
On Tue, Dec 13, 2011 at 3:39 PM, Xavier Wang <weasley.wx@gmail.com> wrote:
> local c = 10
> local function f(a, b) print "a statement" return a + b + c end
In 5.2, you'll need to translate that code to pass c as a parameter to
f if you want it to reuse the closure. Lua 5.2 presently does not
take full advantage of all optimizations available on this. I made
some comments on that on the bottom of [1].
[1] http://lua-users.org/lists/lua-l/2011-11/msg00691.html
> local a = (function(a, b) return a + b end)(10, 20) + 30
> becomes:
> do
> local a, b = 10, 20
> local ret = a + b
> end
> local a = `ret` + 30
That's similar to what [2] does in Metalua.
[2] http://lua-users.org/wiki/SourceOptimizer