lua-users home
lua-l archive

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


On Fri, Oct 9, 2009 at 6:02 PM, Klaus Ripke <paul-lua@malete.org> wrote:
> compilation creates the function body,
> but the assignment to the global fire happens at runtime

Yes, exactly.  So the only way to get some freedom of ordering n a
program is to have a main() call at the very end.  Then the definition
of main can be at the start.  If you want local functions (which are
good for several reasons) in arbitrary order then:

local fun1,fun2

fun2 = function() fun1() end

fun1 = function() print 'fun!' end

fun2()

There is a temptation to write local function fun1 () .. but as
pointed out, that gives you another local!

steve d.