lua-users home
lua-l archive

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

On 30/09/15 03:08 AM, Dirk Laurie wrote:
2015-09-30 2:44 GMT+02:00 Soni L. <>:

The registry, a table, is SLOW. Can we use upvalues instead?
No. The two things are totally different.

The registry, by definition, is a "predefined table that can be used
by any C code to store whatever Lua values it needs to store."

Upvalues, by definition, are "the external local variables that the
function uses, and that are consequently included in its closure".

In C, the distinction is even sharper. The moment you create a new
lua_State, you have a registry, but you don't have any upvalues.
You need a `funcindex` when calling `lua_getupvalue`.

If your question is actually short for "Are there some things that
careless programmers stuff into the registry that would better be
done using upvalues?" then the answer would be "Yes, of course".

In Lua you have 2 options:

1) Use function upvalues. (for local access)

2) Use the module table. (for shared access)

There's no such thing as a "registry" in Lua, it only exists in C (and debug). I want to bring Lua on par with the C API and vice-versa.

I still don't see how the registry is needed, when the Lua side doesn't need one.

Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.