lua-users home
lua-l archive

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


Roberto Ierusalimschy wrote:
> [snip]
> - no more Setglobal/getglobal tag methods: instead, access to global
> variables uses "regular" gettable/settable over the global table.

Am I the only lua user who actually uses getglobal/setglobal?

I have these "special" global variables, which form the execution
environment for the script. These variables are very expensive to
compute, and they are not always required. So I have a specialTag (got
with lua_usertag), and I push the variables, with some

lua_pushusertag(LS, NULL, specialTag);
lua_setglobal(LS, "X");

Then I have a 

lua_settagfunction(LS, specialTag, "getglobal", GetSpecials)

and in GetSpecial I look at the name of the variable, I compute its
value and push it on the stack with

lua_pushnumber(LS, number);
lua_pushnumber(LS, number);
lua_setglobal(LS, "X");
return 1;

(BTW, these special variables are meant to be read-only)

Can this scheme be implemented without setglobal/getglobal?

> - no more tag methods for basic types: only tables and userdata can have
> a "handler-table". Moreover, "basic" tables and userdata (that is, those that
> you did not set a handler-table) cannot have tag methods, either.

I have the (wrong, I hope) sensation that this change will make some
tricks impossible (example: define a bit-per-bit math to be used in a
VRML-like environment). I also assume that the expression "a^b" will
mean "a to the power of b" out-of-the-box...

I hope lua will never lose its marvelous flexibilty. I hope my fears are
not justified.

Regards

Oscar Lazzarino