[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua C libraries
- From: Steve Dekorte <steve@...>
- Date: Fri, 27 Nov 1998 14:19:08 -0800
> >I'd like the math functions to be put into a global table called "math".
> >(Or maybe under the path system.math, etc)
> before calling mathlib_open, set up a "setglobal" tag method to redirect
> all function definitions.
> something like this:
> settagmethod(tag(nil),"setglobal", function (x,v) math[x]=v end)
> after you're done, restore the old "setglobal" tag method.
> if you want to keep the global names, add "rawsetglobal(x,v)" to the code above.
But the that will only get called when a global is set to "nil".
And according to the Lua documentation, it cannot be set for other data types:
4.8 Tag Methods
called whenever Lua assigns to a global variable.
This method cannot be set for numbers, strings, and tables and
userdata with default tags.
I need a setglobal fallback that will get called regardless of type.
Can Lua do that?