[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Function environment table interface
- From: Rob Kendrick <lua-l@...>
- Date: Mon, 6 Jul 2009 21:20:38 +0100
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.