[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Is the registry needed?
- From: Dirk Laurie <dirk.laurie@...>
- Date: Wed, 30 Sep 2015 08:08:15 +0200
2015-09-30 2:44 GMT+02:00 Soni L. <fakedme@gmail.com>:
> 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".