#769 Convention change: contains -> has?

andy Fri 2 Oct 2009

We've been using the convention contains for things that "have" something:

I was thinking the term has might work better (shorter if nothing else). To keep it consistent:

  • List.has
  • Map.hasKey
  • Str.has

Any votes to make that change?

tactics Fri 2 Oct 2009

I think has sounds weird for List and Str. But containsKey sounds weird for Map as it is today. As long as we don't mind them being different, I'd just change it in the case of Map. But uniformity is a nice thing too.

brian Fri 2 Oct 2009

I think they should be uniform since they are all checking if a given value is contained by collection

+1 on changing from contains to has (only because I love shorter names :-)

casperbang Fri 2 Oct 2009

I rather like shorter too - I realize contains is de-facto standard in many languages, but I also think it's simply a habit thing easily overcome. +1.

KevinKelley Fri 2 Oct 2009

ehh... +/-1. Shorter's nice; has and contains mean more or less the same thing; but we're used to contains. I just this morning tripped over trying str.length when it's really str.size.

But in Fan we're generally going for the shortest names that don't lose expressiveness, right? So I kinda lean toward +.

qualidafial Fri 2 Oct 2009

+1 for short names, but.. -1 for this one. contains implies a composite relationship, whereas has implies ownership. On a UML diagram it's the difference between a hollow diamond and a solid diamond. I'm all for brevity but not if we conflate distinct concepts in the process.

jodastephen Fri 2 Oct 2009

This doesn't feel right to me, so I'm -1.

helium Sat 3 Oct 2009

-1

katox Sat 3 Oct 2009

-1, has is shorter but quite uninformative about the operation itself - Str has ... what quality? ahh... it means contains ...

andy Sat 3 Oct 2009

It sounds like even for people who like it, they don't like it enough to make the change. I prefer Map.hasKey over containsKey - but I certainly like contains everywhere else. So lets keep things as is.

ridcully Sat 3 Oct 2009

-1, although Map.hasKey would be ok. But as you write yourself: "they are all checking if a given value is contained by collection" -- so why not use the word contains for this? Perhaps for Map it would be (additionally) possible to have something like Map.keys.contains() or Map.keys().contains() where Map.keys() would be a set of the map's keys.

Login or Signup to reply.