Clean scope

Mike Samuel mikesamuel at
Wed Aug 17 12:04:21 PDT 2011

2011/8/17 John J Barton <johnjbarton at>:
> On Wed, Aug 17, 2011 at 9:14 AM, Juriy Zaytsev <kangax at> wrote:
>> What do you mean by "clean scope"? All scope chains have at least global
>> scope in them. Is that what "clean scope" chain would be — the one including
>> global scope only? That's pretty much what `Function` constructor does.
> No, I mean a scope with JavaScript built-ins only, no 'host'
> functions,  no |window| properties.
> function walkTheWalk(position) {
>  "use empty";
>   var from = parent.location; // error, should have said
> position.parent, but it works?!?
> }

Haven't there been various proposals/schemes for an eval that takes an
object to serve as the scope root as the second argument?

> In SpiderMonkey implementation (built into Firefox, Thunderbird), up to version 1.7, it is possible to pass a calling context as a second argument for eval function.

This violated closures in abominable ways, but it could be made to
respect closures.

If that second argument were explicitly null, then using an object
containing only the builtins as defined at interpreter start, would
get these semantics.

More information about the es-discuss mailing list