lua-users home
lua-l archive

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


Luiz Henrique de Figueiredo wrote:
> 
> >Oh, yes, I know the names "a priori". But this way EVERY time I use a
> >global variable the tag method is called...
> 
> Yes, I'm aware of that. :-( You might also set the "index" TM on the global
> table to check for the special names and if so compute them. In this way, the
> special vars are never actually global vars. (If the values don't change, you
> may add a cache table.)
>
> [snip]
>
> The setglobal/setglobal methods come from a time when globals were
> really distinct entities.

In my humble opinion, I think the problem is that the gettable and index
tag methods are on the global table, rather than on the global
variables. I think this makes globals distinct entities even more than
in lua 4.0. I think a nice solution would be to ADD two tag methods
"set" and "get" on variables. This methods would substitue the
getglobal/setglobal pair, because they would work on every variable for
which the TM is set (local or global, in a table or not).

Oscar Lazzarino