lua-users home
lua-l archive

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


I run 'lua foo.lua', where foo.lua contains:

A=1
local A=2
f=load('return A')
function g() return A end
print (f(),g())

The output is
1       2

I extrapolate from this example to conclude that:

1. 'load' sees no local variables from the block in which it
    is executed, neither does 'loadin'.
2. 'load' can be appear anywhere in the code, with no change in 
    its effect, as long as the function defined by it exists 
    by the time that it is called.
3. 'function', on the other hand, can see local variables and its 
    effect therefore does depend on where in the code it stands.

Right?

Dirk