lua-users home
lua-l archive

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



> On Behalf Of Rici Lake
> 
> On 31-Aug-04, at 7:32 PM, Nick Trout wrote:
> 
> > You cannot declare functions in Lua. Local values will be concreted
in
> > the function closure made. If you can't move func2 before func1
you'll
> > have to make a global variable that accesses func2. Global variables
> > are
> > lazy evaluated so you can set them anytime before you need to use
them.
> > Local variables are evaluated when they are parsed and the reference
> > made concrete.
> 
> Not quite; Asko is quite right:
> 
> local func1
>     -- declares the local func1
> 
> local function func2(x) return func1(x + 1) end
>    -- uses the local func1
> 
> function func1(x) return func2(x - 1) end
>    -- assigns a value to the local func1

Ah, func1 is in the outer scope. Ignore my ranting, sorry. 

Nick