lua-users home
lua-l archive

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


I'm not taking sides on the __len semantics issue, but most of what would be
needed to implement pure Lua objects would be to provide a function taking a
metatable and a regular table and returning a userdata with that metatable
and the regular table as its environment. It makes the code implementing the
object a little more complicated in that it needs to go retrieve the
environment table, but it means that you get all of the behaviors associated
with userdata values. Furthermore, one could use it to implement opaque
objects by making the environment hidden to standard Lua calls and instead
using a private weak table to retrieve it.

Mark