[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: wish for 5.2
- From: Hans van der Meer <H.vanderMeer@...>
- Date: Thu, 12 Feb 2009 21:13:29 +0100
I do not know if the details for Lua 5.2 are already frozen.
But allow me to bring forward a few ideas that might be useful in my
opinion.
(1) extension of the luaL-check.. and luaL_opt.. repertoire with
functions for the retrieval of booleans.
Allthough easily added with macros, their absence breaks the
completeness of the retrieval functions.
(2) at least one extra table slot on userdata.
At the moment a userdata item may be given a metatable table where
functions can be registered on it. That way it can enter a __gc
function on garbage collection and can be used in an object oriented
manner. With luaL_newmetatable and luaL_checkdata it can be given a
signature, which I find very useful.
However, the need arose to store different data in individual userdata
items of the same sort. The general metatable cannot be used here,
because then all these userdata will share that data, which is not the
intention.
I solved it by giving each userdata item its own metatable. But then
the signature mechanism is thwarted and for oo access each individual
userdata must be given the full set of callable functions.
A more attractive approach, in my view, would be to allow setting on
the userdata another table besides the metatable. In the metatable the
general behaviour can be registered, and the other table is available
for the storage of individual data.
Is this a viable suggestion? I could not think of any other solution
other than the aforementioned individual metatable. Because the
userdata and tables cannot be reconstructed from lua_topointer or
lua_lightuserdata conversions, I see no way to store these items in
the user-accessible part of a userdata.
But maybe I missed something.
Hans van der Meer