[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Creating closures (or not)
- From: Peter Cawley <lua@...>
- Date: Mon, 12 Jul 2010 19:35:20 +0100
Wherever you see "function", a closure is created. Otherwise you
wouldn't be able to set the environment of the resulting function
without affecting other functions.
On Mon, Jul 12, 2010 at 7:32 PM, Geoff Leyland
<geoff_leyland@fastmail.fm> wrote:
> Hi,
>
> Does
>
> function f()
> return function() end
> end
>
> create a closure, or are closures only created if the inner function uses one of f's locals (or a local from an outer scope) as an upvalue? I'd like to know if the above causes any more heap allocations than:
>
> local function g() end
> function f() return g end
>
> Cheers,
> Geoff