Is ES5 Strict a fully statically scoped language?

Šime Vidas sime.vidas at gmail.com
Wed Oct 3 16:49:42 PDT 2012


On Thu, Oct 4, 2012 at 12:31 AM, Mark S. Miller <erights at google.com> wrote:

>
> On Wed, Oct 3, 2012 at 3:16 PM, Šime Vidas <sime.vidas at gmail.com> wrote:
>
>> On Wed, Oct 3, 2012 at 7:05 PM, François REMY <fremycompany_pub at yahoo.fr>wrote:
>>
>>>   I think that what he meant is that we know for sure in which scope we
>>> can find the property/variable. That the propery exists or not in the that
>>> scope is another issue.
>>>
>>
>> So, it doesn't matter that the global environment is dynamic (as in
>> bindings can be added/removed dynamically), since it's the top-most
>> environment. Only the nested (function) environments must be static, and if
>> they are, i.e. if we know which bindings are defined in each function
>> environment (in the scope chain), then we can safely assume that a name
>> that doesn't exist in any of those function environments, can only either
>> be a global binding, or a name that doesn't exist in any environment. Did I
>> get this correctly?
>>
>
> Exactly correct. Thanks for the clarification!
>



Well, thank you for your excellent video. The dynamic scopes in the default
language are a disaster... I've just written a short code example (see
below) which demonstrates this. Thank goodness ES5 Strict is statically
scoped. :-)

// global code
this.foo = 1;

(function () {
    eval('var foo = 2');

    with ({ foo: 3 }) {
        foo // => 3
        delete foo;
        foo // => 2
        delete foo;
        foo // => 1
        delete foo;
        foo // ReferenceError
    }
}());
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121004/a8acd89e/attachment.html>


More information about the es-discuss mailing list