Adding methods to {Array,String}.prototype

Brendan Eich brendan at mozilla.com
Fri Jul 29 10:08:53 PDT 2011


On Jul 29, 2011, at 9:53 AM, Axel Rauschmayer wrote:

>> I like Underscore (http://documentcloud.github.com/underscore/). Should we standardize it? Not yet. But it points in the right direction to avoid OOP single-inheritance traps: functional programming, generic for all containers functions.
> 
> I love true generic functions (as in “multiple dispatch”) and think that they would be a good match for JS (not any time soon, but one can dream). I see generic functions as complementary to single dispatch (including prototypes). Reenskaug and Coplien [1] seem to agree. Generic functions are also great for working with data coming from web services (e.g. JSON).

I did not mean multimethods ("generic functions" is a confusing term, since it also means functions that work for parameters of any time; also "generic" suggests "generics", i.e. type parameters).

ES4 had a proposal for multimethods but I doubt it will make a come-back. Adding another dispatch mechanism to JS is a very hard sell. For dyadic operators, double dispatch is enough.

/be



More information about the es-discuss mailing list