<div class="gmail_quote">On Thu, Oct 4, 2012 at 12:31 AM, Mark S. Miller <span dir="ltr"><<a href="mailto:erights@google.com" target="_blank">erights@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br><div class="gmail_quote"><div class="im">On Wed, Oct 3, 2012 at 3:16 PM, Šime Vidas <span dir="ltr"><<a href="mailto:sime.vidas@gmail.com" target="_blank">sime.vidas@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="gmail_quote"><div>On Wed, Oct 3, 2012 at 7:05 PM, François REMY <span dir="ltr"><<a href="mailto:fremycompany_pub@yahoo.fr" target="_blank">fremycompany_pub@yahoo.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div dir="ltr">
<div dir="ltr">
<div style="font-size:12pt;font-family:'Corbel'">
<div>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.</div></div></div></div></blockquote></div><div><br>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?<br></div></div></blockquote><div><br></div></div><div>Exactly correct. Thanks for the clarification!</div></div></blockquote><div> </div><div><br><br>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. :-)<br>
<br><div style="margin-left:40px"><span style="font-family:courier new,monospace"><span class="js-comment">// global code</span></span><br><span style="font-family:courier new,monospace"><span class="js-variable">this</span><span class="js-punctuation">.</span><span class="js-property">foo </span><span class="js-operator">= </span><span class="js-atom">1</span><span class="js-punctuation">;</span></span><br>
<span style="font-family:courier new,monospace"></span><br><span style="font-family:courier new,monospace"><span class="js-punctuation">(</span><span class="js-keyword">function </span><span class="js-punctuation">(</span><span class="js-punctuation">) </span><span class="js-punctuation">{    </span></span><br>
<span style="font-family:courier new,monospace"><span class="whitespace">    </span><span class="js-variable">eval</span><span class="js-punctuation">(</span><span class="js-string">'var foo = 2'</span><span class="js-punctuation">)</span><span class="js-punctuation">;</span></span><br>
<span style="font-family:courier new,monospace"><span class="whitespace">    </span></span><br><span style="font-family:courier new,monospace"><span class="whitespace">    </span><span class="js-keyword">with </span><span class="js-punctuation">(</span><span class="js-punctuation">{ </span><span class="js-property">foo</span><span class="js-punctuation">: </span><span class="js-atom">3 </span><span class="js-punctuation">}</span><span class="js-punctuation">) </span><span class="js-punctuation">{</span></span><br>
<span style="font-family:courier new,monospace"><span class="whitespace">        </span><span class="js-variable">foo </span><span class="js-comment">// => 3</span></span><br><span style="font-family:courier new,monospace"><span class="whitespace">        </span><span class="js-keyword">delete </span><span class="js-variable">foo</span><span class="js-punctuation">; </span></span><br>
<span style="font-family:courier new,monospace"><span class="whitespace">        </span><span class="js-variable">foo </span><span class="js-comment">// => 2</span></span><br><span style="font-family:courier new,monospace"><span class="whitespace">        </span><span class="js-keyword">delete </span><span class="js-variable">foo</span><span class="js-punctuation">; </span></span><br>
<span style="font-family:courier new,monospace"><span class="whitespace">        </span><span class="js-variable">foo </span><span class="js-comment">// => 1</span></span><br><span style="font-family:courier new,monospace"><span class="whitespace">        </span><span class="js-keyword">delete </span><span class="js-variable">foo</span><span class="js-punctuation">;</span></span><br>
<span style="font-family:courier new,monospace"><span class="whitespace">        </span><span class="js-variable">foo </span><span class="js-comment">// ReferenceError        </span></span><br><span style="font-family:courier new,monospace"><span class="whitespace">    </span><span class="js-punctuation">}    </span></span><br>
<span style="font-family:courier new,monospace"><span class="js-punctuation">}</span><span class="js-punctuation">(</span><span class="js-punctuation">)</span><span class="js-punctuation">)</span><span class="js-punctuation">;</span></span><br>
<span style="font-family:courier new,monospace"></span></div> </div></div><br><br>