lua-users home
lua-l archive

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


On Wed, 20 Jan 2010 09:56:25 +0200, Mark Hamburg <mark@grubmah.com> wrote:

Userdata environments are unaffected. The only thing they had in common with function environments was the API that happened to be used to get and set them. The existing C API routines could be renamed lua_getudenv and lua_setudenv under this proposal.

Almost yes, but unfortunately, no. Currently lua_newuserdata does this:

u = luaS_newudata(L, size, getcurrenv(L))

which is imho unnecessary, and I do change it locally, but still:
  == every userdata by default has a reference to current environment ==
I really hope there is no existing code that relies on this.
It creates extra GC references, and may accumulate garbage.
</rant>
Other than that, having variable number of TValues associated would
be much more useful (similarly to how CClosure now has it).

As I said, this language has different semantics from Lua with respect to globals, but it's probably not as different as one might think for most code.


And the patch might not be that big ... :)