lua-users home
lua-l archive

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


On Fri, Oct 09, 2009 at 10:45:10AM -0500, Phoenix Sol wrote:
> On Fri, Oct 9, 2009 at 2:32 PM, steve donovan <steve.j.donovan@gmail.com> wrote:
> > Lua order is pretty flexible, though you do have to declare local
> > functions up front as locals...
> 
> Global functions, too, I noticed. I'm kinda surprised, since there is
> always a compilation step before execution. (But I'm still very
> ignorant of Lua's implementation.)
...
> fire()
> function fire() print('foo') end  --global

compilation creates the function body,
but the assignment to the global fire happens at runtime

it is really
fire = function () print('foo')
http://www.lua.org/manual/5.1/manual.html#2.5.9

yet local makes it worse by creating a _new_ local variable


cheers