[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: setglobals and Lua 5.0
- From: "paul_winwood" <paul_winwood@...>
- Date: Thu, 17 Apr 2003 08:04:40 -0000
>The way this used to work for Lua version 4.x was I would trap the
>getglobal using a tag method and then I would redirect this to the
>zeus_function where I would test if a call to a Zeus builtin
>function was required.
With Lua 5 globals are just another table accessed by the special
index LUA_GLOBALSINDEX, therefore the getglobal tag method is
redundant. You should be able to set a metatable on the globals table
and then install __newindex or __index or __call (as required)
metamethods. See the Metatables section of the Lua 5.0 manual for
more info.
I am about to release version 2 of wxLua that uses Lua 5.0 and I must
say when you get your head around the change it is much more rational
and consistent.