6 ms·
> Everything in the language is a thing that you can redefine. Pretty much goes for any dynamic language, perl/ruby/javascript/etc...
by AjithAntony 14y ago
> Everything in the language is a thing that you can
redefine.
Pretty much goes for any dynamic language, perl/ruby/javascript/etc...
- masklinn 14y agoNot really, javascript provides very little core behavioral hooks for instance: no creation hook (new/__new__, yeah you can return your own instance in the constructor but it'll still build an instance regardless), no general attribute-access until proxies (method_missing/__getattr__), no operators override (save through toString/valueOf hacks and that won't work for []), no conversion hooks (again, aside from toString/valueOf), etc... Compare and contrast: http://docs.python.org/3/reference/datamodel.html#special-method-names http://docs.python.org/3/reference/datamodel.html#special-me... Ruby provides roughly the same level of hooking (not sure it allows overriding instance or subclass checks, but it allow overriding things Python does not as well), but JS most definitely does not.
- Benvie 14y agoAll of these things are coming as part of the next version of JavaScript, ES6. Proxy is available in Firefox and Chrome behind a flag. Function.prototype.@@create/@@hasInstance is in the ES6 spec.
- masklinn 14y agoAnd thus these things don't "go" for javascript. They might do so in 5 years, informed by the rest. But now, nope.
- ConceptJunkie 14y agoOn the plus side, I checked: Mr. Dunderbak (note spelling) is still around. Now I'm all hungry. Also I definitely need to learn more about Python. It's always deeper than I realize.