On Sunday, May 20, 2012 at 3:31 PM, Strager Neds wrote: 
> I agree with Alle
> 
> 

> I don't see the point in adding String#contains if `str.indexOf(x) >=
> 0` is equivalent (just like with arrays).
> 
> For sets, doing something like indexOf doesn't make sense (and a large
> part of sets is testing for inclusion, not indexing). For maps, the
> 'in' operator is unsuitable (as we all know from using a plain object
> as a hash map). Thus, both deserve a specialized method for these
> predicates.
> 
> In a further attempt to avoid confusion, would distinct 'hasKey' and
> 'hasValue' for Map.prototype be a good idea (instead of jumping around
> between has, contains, includes, isMember, etc.)?
> 
> (I'm at a loss to find the 'spec' being discussed; could someone point
> me in the right direction? I'm new to this list.)
> 
> 


http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets


Rick
 
> 
> On Sun, May 20, 2012 at 12:16 PM, Allen Wirfs-Brock
> <[email protected]> wrote:
> > 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
> > 
> 
> _______________________________________________
> 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