lua-users home
lua-l archive

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


On Mon, 6 Jul 2009 21:30:43 +0100
Peter Cawley <lua@corsix.org> wrote:

> > 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?

> Firstly, environment tables are per-function, whereas all functions
> share a single metatable, so function environments could not be set
> via metatable. Secondly, separating the environment from the metatable
> allows for one to be per-instance and one to be per-class. 

I can't quite think of a reason why you'd want the environment to be
per-instance, and not some of the other metatable fields, but OK.

B.