[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: modules and locals
- From: Drake Wilson <drake@...>
- Date: Mon, 23 Aug 2010 14:27:13 -0700
Quoth Andreas Matthias <andreas.matthias@gmail.com>, on 2010-08-23 23:11:15 +0200:
> function foo()
> bar()
> end
>
> local function bar()
> end
[...]
> What's going on here? I don't understand it.
The scope of a lexical local starts after its declaration and extends
to the end of the containing block. A local function is just like any
other local variable in that regard. One way of doing what you seem
to want is to declare « local bar » above, then use « bar = function()
... end ». Another, more obvious way would be to just let it be a
'global' (in the current environment table).
> Ciao
> Andreas
---> Drake Wilson