On 2008-07-31, at 08:24EDT, Dave Herman wrote: >> We should take this problem seriously. ... >> Dynamic scope is very bad. > > Specifically: > > - Classes are supposed to provide integrity, but dynamic scope makes > the internals of code brittle; any variable reference inside the > implementation could be subverted by the seemingly innocuous > insertion of a property. > > - Dynamic dispatch has a reasonably understandable cost model, but > only if it's confined to explicit property references. With dynamic > scope, any variable reference could potentially be very expensive. > > - Generally, code within a `with' block is brittle and hard to > understand, and as Tucker says, the implicit `this.' means that all > code inside class methods is within a `with' block... this means > that all code inside class methods is brittle! > > - In the past, this has been enough for many programmers to > deprecate all use of `with' -- we should certainly hope to avoid the > same happening for classes.
CLOS (Lisp) has something very like 'reformed with' to let you write shorter method bodies without magic: http://www.lispworks.com/documentation/HyperSpec/Body/m_w_slts.htm Here's my take at an example of brittleness: var bar = 42; class foo { function zot () { return bar; } } ... class subfoo extends foo { var bar = 'oops!'; } (new foo).zot() => 42 (new myfoo).zot() => ? _______________________________________________ Es4-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es4-discuss
