lua-users home
lua-l archive

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


Roberto Ierusalimschy <roberto <at> inf.puc-rio.br> writes:

> 
> > So I guess I'm wondering: is there any reason why Lua doesn't let
> > userdata have a custom mark function?  It would allow me to implement my
> > extension much more efficiently.
> 
> Note that the Lua API does not have anything like a PyObject type. Lua
> values have no representation in C at all. So, what would be the use
> of a mark function? Where would it get the Lua objects to mark? If the
> mark function can access a Lua object, this object is accessible and
> therefore will be marked by Lua, without the need of a mark function.

Hmm, I hadn't realized that.  I hoped that there would be a way to store/recall
arbitrary Lua objects as an opaque void*, even if there was no way to interpret
or dereference its data.  It would be nice if Lua could support this.  Otherwise
extensions aren't able to create optimized container types.  Tables are very
versatile, but there are times when a different container type would be better.

Josh