lua-users home
lua-l archive

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


2008/11/18 Bogdan Marinescu <bogdan.marinescu@gmail.com>:
> 2. rotables: maybe a better name for them would've been "romtables",
> but I found that to be a little too technical. They are read-only
> tables, but unlike the read-only tables that one can already implement
> in Lua with metamethods, they have a very specific property: they
> don't need any RAM at all. They are fully constant, so they can be
> read directly from ROM. Their only purpose is to allow one to register
> a module without having to allocate a table in RAM, and because they
> are such a "specialized" data type they have many restrictions:
>
> - rotables can only contain values of type "lightfunction" or
> lua_Number at the moment. "Embedded" rotables (rotables containing
> references to other rotables) are planned for a future release.

What about the restrictions on the keys ?

> - you can't iterate over rotables with pairs()

I think overriding (lua_)next and pairs should be pretty easy to
accomodate for your new datatype.

> - you can't add/delete/modify elements from rotables (obviously)
> - you can't set a rotable as a metatable (but I'd like to change this
> in a future release if possible).
> - rotables can't have metatables.
>
> Just as with lightuserdata, you can only create lightfunctions and
> rotables from C code, never from Lua itself.