lua-users home
lua-l archive

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


Lenny Palozzi wrote:
> 
> A = function(t) -- constructor A
>         t.getName = function(self) return self.name end
>         return t
> end
> [...]
> FUNC = function(self) return self.name end
> 
> A = function(t)
>         t.getName = FUNC
>         return t
> }
> 
> This could potentially save you plenty of memory.

In Lua 3.2 that would give exactly the same results.  Only
in Lua 4.0 every function statement creates a closure.  In
3.2 it was only created when the function had upvalues.

I already wrote a longer mail about this hmm... misfeature ;)
(Look for "Shared activation records are cheaper" or so) 

Ciao, ET.