Oops, accidentally sent this only to Allen.
---------- Forwarded message ---------- From: Jason Orendorff <[email protected]> Date: Tue, Mar 3, 2015 at 11:34 AM Subject: Re: Class double-bind To: Allen Wirfs-Brock <[email protected]> On Mon, Mar 2, 2015 at 5:54 PM, Allen Wirfs-Brock <[email protected]> wrote: > Pretty much everyone I've seen discover the function binding equivalent (or > have it explained to them for the first time) was shocked. What! 'function > fact(n) {return n>1? n*fact(n-1):1}' doesn't necessarily recur on the same > function? that's crazy! is the typical reaction. Perhaps this is a little overstated? In Scheme, Python, Lua, Ruby, and Smalltalk, code in a function/class/method that refer to it by name refer to the external binding. That binding is mutable in all those languages except Ruby and Smalltalk (and even in those, I think you *can* mutate it, but the language discourages it). So basically every language in this space has the same behavior. JS differs only in that it has a named-function-expression syntax, which I think the others lack. I can't think of a language where two bindings are created and they can then diverge. This is novel weirdness. > Similarly, it would be crazy if: > class Foo { > static makeFoo() {return new Foo} > } > > didn't give you a factory method that created instances of Foo. Well, you're calling every existing dynamic language with classes crazy. I don't think that's very useful. >> If we wanted classes to be tamper-proof, then the outer binding would >> be immutable as well. It's not; it's mutable; yet every use case I can >> think of for actually assigning to it is silently broken due to the >> double binding. > > We needed global class bindings to be replaceable. That makes sense. -j _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

