lua-users home
lua-l archive

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


> On Aug 19, 2015, at 11:49 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 
> I think I understand it now, thanks to the messages of the past
> 16 hours. (In my timezone, people are just waking up.) The
> OP's use case has been clouding the issue. What is being
> proposed is much more versatile.

….

Good summary :) .. But I’m not sure I’m on board with the idea...

Since userdata is opaque to Lua, any operation on that userdata must involve a call to a C function with the userdata as an argument. Once you do this, all the issues discussed here go away; it’s easy to provide the extra metadata about a userdata using any number of indirection/tagging techniques at the C level, including lifetime management if you want to (for example) refcount etc.

However, any such technique is of course private to each developer. In addition, they will typically involve a more complex low-level C model (struct with pointers to structs etc). So the question is: Would there be a benefit in having an “official” way for Lua to perform this in a generic manner that everyone could leverage?

My opinion is NO, for the following reasons:

— Lua already has metatables and uservalues that can be attached to userdata. Why isn’t a conventional use of these facilities adequate?
— I think it would be difficult to come up with a design that was both sufficiently flexible and compact.
— As you have noted on many occasions, Roberto et al are very unlikely to consider such an addition unless there is a very strong case for it.

—Tim