[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: disabling global definitions within function blocks
- From: "xenarcher <nickl@...>" <nickl@...>
- Date: Tue, 07 Jan 2003 23:30:20 -0000
--- In firstname.lastname@example.org, "xenarcher <nickl@v...>" <nickl@v...>
> When foo() is called, no error occurs. Is there a way to propagate
> "read-only globals" to all function calls (at any level
> of nesting) following the setglobals() call?
Actually, I just figured out a way to do this, though it's a little
hacky... I loop over all variables defined in the global table, and
called setglobals() on each variable that is a function (*). This
seems to work well.
Now there's one remaining problem I'd like to solve. Say you have the
SomeVariable = 1
AnotherVariable = 0
AnotherVariable = SomeVariabl -- NOTE THE TYPO!
The default behavior is to return nil for the undefined global. Is
there a way I could flag this as an error instead?
(*) Trying to call setglobals() on a C function raises an error,
since setglobals() may only be called on Lua functions.
Unfortunately, there doesn't appear to be a built-in method of
distinguishing C functions from Lua functions, so I had to provide my
own custom method of doing so through the C API.