SE-0207: Add a containsOnly algorithm to Sequence

SE-0207 Core Team Interim Report / Feedback Request

In today's core team meeting, we discussed three possible variations of the overload that takes a predicate:

  1. studentBody.containsOnly(where: gradeIsAPlus)
  2. studentBody.containsOnly(elementsWhere: gradeIsAPlus)
  3. studentBody.containsOnly(gradeIsAPlus)

These choices reflect different prioritizations of principled values, and we are trying to decide which principles should win out. The eventual decision will set a precedent that will help us evaluate similar bikesheds in the future. The core team sent me back to the evolution list to try to gather relevant signal.

The main argument for #1 (what's in the proposal) is that in the standard library, all unary predicates are currently labeled with where: or while:, or are unlabeled. The principle is that surface uniformity of similar constructs is valuable; it makes code (including new APIs) easier to write and APIs easier to find.

The main argument for #2 is that our API guidelines say we should “prefer method and function names that make use sites form grammatical English phrases.” That principle was followed in choosing the standard library's current names, and the existing uses of where: don't have a basic grammaticality problem, but usage #1 does: a noun is missing.

The main argument for #3 is that usage is still quite clear, and it would be better not to try to achieve grammaticality than to go partway there but fail (as in #1). [Note that as far as the compiler is concerned, this choice is unambiguous with the other overload because closures are not Equatable]. The principle here is that in the absence of a difference in clarity, shorter/smaller APIs are better.

The core team would very much appreciate your input on how to weigh these principles.

Thanks,
Dave