lua-users home
lua-l archive

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


On 12 July 2010 14:39, Geoff Leyland <geoff_leyland@fastmail.fm> wrote:
> Thanks Peter!  That makes sense (in hindsight...).  In that case, does
>
> function f()
>  return function() end
> end
>
> f(); f(); f(); f(); f()
>
> create more heap objects than
>
> local function g() end
> function f() return g end
>
> f(); f(); f(); f(); f()

Yes. It's semantically different as well: in the first case a setfenv
on one of the returned functions would not affect the others, since
they are all separate objects, but in the second case setfenv would
affect them all, since they are all the same object.

    henk