[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: Luiz Henrique de Figueiredo <lhf@...>
- Date: Tue, 13 Dec 2011 18:16:22 -0200
> local a = (function(a, b) print "a statement" return a + b end)(10, 20) + 30
Lua 5.1 will create a new closure every time this statement is execute.
Lua 5.2 will not: it will resuse the closure.
Try the code below in each version:
for i=1,3 do
local f = function(a, b) print "a statement" return a + b end
local a = f(10, 20) + 30 + i
print(f,a)
end