lua-users home
lua-l archive

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


Separate environments are the issue. If one wanted inheritance, one can get
that by creating appropriate environments.

Note that this is more a theoretical question as opposed to a specific issue
with venv. It came up because method chaining could benefit from using
custom function environments, but it isn't really safe for the class
constructor to just slam the function environment since the environment may
already have been changed in some other use of a function.

Mark

on 7/6/05 1:15 PM, Tomas at tomas@ccpa.puc-rio.br wrote:

> Hi Marc,
> 
>> It doesn't, however, address the issue I was raising since when it does a
>> setfenv on the function to be wrapped, it will stomp any existing
>> environment. In particular, I can't write:
>> 
>>    f1 = venv( f )
>>    f2 = venv( f )
>> 
>> And have separate environments for the functions.
> You are right.  venv() is changing the environment of the given
> function.  I've just corrected that, but if the given function had an
> environment different from the global, it will be ignored.  I'm still
> trying to solve this...
> What I missed is if you need just the separate environments or
> if you need also that the new environment inherit from the old one.
> 
> Tomas