lua-users home
lua-l archive

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


Kevin Martin <kev82@khn.org.uk> writes:
> I'm only just getting my head around this at the moment, but I think
> you automatically get this behaviour in lua 5.2.
>
> As I understand it, if you load the function, then change the first
> upvalue to be the table associated with your c++ object. That table
> will the become the global environment for the function, and anything
> it calls.

No.

[Many people seemed to have _thought_ that's how things worked in 5.2,
but they were wrong.]

The global environment reference in 5.2 is still "static", as it was
in 5.1, but now it uses an upvalue instead of a special environment
slot in the function.

-miles

-- 
The trouble with most people is that they think with their hopes or
fears or wishes rather than with their minds.  -- Will Durant