4 ms·
Agreed. Maybe an example of how JavaScript/CoffeeScript would behave if it had dynamic scope semantics could help: // In dynamically scoped JS... var f = f
by epidemian 14y ago
Agreed. Maybe an example of how JavaScript/CoffeeScript would behave if it had dynamic scope semantics could help:
// In dynamically scoped JS...
var f = function() { alert a; }
f(); // would throw an error as expected, but...
var g = function() {
var a = 5;
f(); // would now work because `a` now exists.
} // The scope of `a` ends here though, so...
f(); // would throw again, but if we give life to the dinamically scoped `a` again...
var a = 6;
f(); // now works! Printing 6 as "expected" (at least after swallowing dynamic scope).
- raganwald 14y agoFrom the vicious flame-fest that precipitated this post: x = 'lexical' acid = -> alert "#{x}ly scoped" test = (x) -> acid() test('dynamic')