[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: setfenv/getfenv
- From: Nevin Flanagan <Alestane@...>
- Date: Tue, 12 Jan 2010 17:20:46 -0500
On Jan 12, 2010, at 4:45 PM, Cosmin Apreutesei wrote:
> Callers can only influence the
> function's behavior through it's public interface, i.e. it's
> arguments. The function's environment is not part of that interface,
> so callers shouldn't try to mess with that environment to change the
> function's behavior that way.
I think this is a big part of it. I do, however, think there is a place for taking code you're not responsible for authoring and constraining it into an environment of your choosing. What appeals to me about the "closure clone" concept is that it allows you to do this in many cases, but doesn't force other code built around the original function from also using the new behavior; since the function with the new environment is a separate object, other code will keep its original copy with the previous environment.