These really don't seem all that similar:

Map "has" is looking for a specific key used for the elements of a collection 
(Sets can be thought of as collections where keys and values area always the 
same)
String "contains" is a search for a specific sequence of element values.  One 
is about keys, the other is about values.  One is about single elements, the 
other is about sequences of elements.

Consistent naming is important, but in this case I think using the same name 
would be conflating things that are actually quite different.

It seems to be that there are at least three dimensions of variability we 
should be considering when selecting consistent names for these kinds of 
operations:

1) are they operating over object properties or elements of an abstract 
collection
2) are the looking at keys or at values
3) are they looking at individual elements or at sequences of elements

We wouldn't fill in this entire matrix and we have to live with legacy naming 
decisions, but it would be nice if going forward we consistently used method 
names that conformed to such a model.

Allen




On May 20, 2012, at 2:46 AM, Tobie Langel wrote:

> Hi,
> 
> The lack of consistency between the naming of
> `String.prototype.contains` and `(Set|Map).prototype.has` bothers me
> (a little).
> 
> Both Ruby and Python display consistency for this (through the
> `include?` instance method and `in` operator respectively).
> 
> Maybe that's been discussed on the list already (can't find a search
> function for the archives, unfortunately).
> 
> If not, may I suggest both methods should be named the same?
> 
> And for extra consistency, an Array.prototype.(contains|has) would
> also be a nice addition.
> 
> Thanks for your time,
> 
> --tobie
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
> 

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to