lua-users home
lua-l archive

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


Hi,

I just had a thought; why are function environments not implemented via
a field in a metatable?  For example;

	setmetatable(func, { _env = sometable })

rather than;

	setfenv(func, sometable)

While I can't see how it makes any functional difference to how they
are done, it does mean there is only one interface the programmer has
to remember rather than one, as well as removing two functions that
pollute the global namespace.  It also feels more orthogonal and
consistent.

What am I missing?

B.