Benjamin (Inglor) Gruenbaum (2013-10-13T18:00:45.000Z)
domenic at domenicdenicola.com (2013-10-28T15:17:42.083Z)
Brendan Eich <brendan at mozilla.com> wrote: > No, object detection, polyfilling, and even "prollyfilling" are common and successful adaptationsp on the Web. Polyfilling is great _after_ the method has already been added to the spec. I'm completely fine with adding an Array.prototype.map shim to IE8, the problem with adding a method that's not on the prototype yet is that it'll fail in case the spec is different from the implementation I chose. If you mentioned PrototypeJS, its `.bind` method is one such example. > Your subject recalls a defunct proposal to add lexically-scoped but heap-based -- therefore object property-lookup performance hindering -- extension properties. I have to say this surprises me, a performance issue is the last thing I expected. What about attaching a prototype as a closure variable, something (and this is a syntax I __don't__ like) like: ``` (function(use Array){ Array.prototype.contains = function() { ... ... // any code here has access to .contains, code that did not originate here does not have such access, much like a closure. // other code is free to use Array without any collisions. })() ``` Again, I __don't__ like this sort of syntax and I'm __not__ sure about the semantics here, I just noticed I have this problem - I'm probably not the most qualified for coming up with the solution out of the amazing minds right here. > but for the record, string-equated names have been and will be used to extend standard built-ins too. I completely agree here. I'm stoked about symbols just like the next guy but using symbols here (with the bracket syntax) seems unnatural and not what I intended to do. Kevin Smith <zenparsing at gmail.com> wrote: > That's what the symbol registry will solve, though. That's an interesting approach. However, even if we overlook the (maybe somewhat abusing?) nature of using something like the symbol registry for coordinating global state like this. I think this can appear as somewhat of an overkill for something that sounds to me a common problem and a reasonable use case. I just thought it would be really nice to have things like NodeList.prototype.sort or Array.prototype.shuffle without worrying about conflicts with other libraries or the language itself in a few years.