Array.prototype.contains solutions

Brendan Eich brendan at mozilla.org
Tue Jan 20 10:24:26 PST 2015


Domenic Denicola wrote:
> https://www.google.com/search?q=site%3Aesdiscuss.org+Array.prototype.contains+solutions  leads tohttps://esdiscuss.org/topic/array-prototype-contains-solutions  which is probably what you were thinking of.
>
> They were not very good ideas.

It's a hard problem. Original-JS2/ES4 had namespaces, after Common Lisp 
symbol packages, as a proposed solution. You'd have to open a namespace, 
e.g.

   use namespace intrinsic;
   if (myArray.contains(someValue)) ...;

or explicitly quality:

   if (myArray.intrinsic::contains(someValue)) ...;

in case you needed to mix MooTools' contains with the new built-in one.

Namespaces were decisively rejected from the Harmony agenda at its 
founding in Oslo, July 2008:

https://mail.mozilla.org/pipermail/es-discuss/2008-August/006837.html

General hacks tend to generalize to namespaces if you push them. 
Specific hacks as you say are not very good ideas. This leaves picking 
good-enough names that don't collide. AFAIK this is the state of the 
art. Just recapitulating for anyone new to es-discuss, and calling for 
better ideas. Thanks,

/be



More information about the es-discuss mailing list