lua-users home
lua-l archive

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


Peter Hill:
>  Is this "getglobals" of a *number* a good idea? It sounds rather
> dangerous (especially since it is prey to optimisation). =:-O

RLake:
> The main reason to getglobals(L, 2) from C is to be able to feed it
> into a newly created Lua closure.

So "getglobals(L,2)" is common but "getglobals(L,3)", "getglobals(L,4)", etc
isn't? If that is the case then maybe we just need a function to find the
caller's globals? Hmm, I guess that is actually just the same thing (if you
ignore the tail call problem) :-(.


Peter:
> This "getglobals" of a number makes me nervous :-O.

RLake:
> I agree. But what is the solution?

How about this as an alternative... I've been wondering if functions having
a global table should be optional. Ie, if you did "setglobals(func, nil)"
then "func()" would be set to have no global table, and would instead
inherit its parents one.

Since, according to Roberto, C functions rarely use their own global tables
anyway, and can just as easily use any other table, this would enable the
desired behaviour.

Does that sound feasible? It is somewhat more limited so I guess the
question is... does it cover the useful cases?

*cheers*
Peter Hill.

Ki: Contractors... high-paid leeches stealing our work.
Fooker: If you think of them as disposable employees, you'll feel much
better...