lua-users home
lua-l archive

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

I think userdata "environments" are mostly fine as they are though two changes would make them easier to use.

1. Allow nil environments for userdata. This slightly complicates the GC, but it means avoiding marking a stub table over and over again for userdata that doesn't need an environment. From a programming standpoint, it helps in some cases where one needs to take different action if a userdata has a custom environment. (Lightroom's Objective-C bridge treats objects with associated Lua references differently.)

2. Provide a pseudo-index for accessing the environment table of the first stack entry (which must be a userdata). This simplifies writing methods for native objects that use the environment table to hold Lua references.