Closed dabrahams closed 4 years ago
Thank you for the feedback, Dave! Both changes to the name were based on conversations among the standard library team, as well as others:
partitioning
is intended to make reading the method name more natural and less ambiguous. While partition
can be read as a noun, it exists in the standard library as a verb, and can cause confusion when presented in the same tense as a modifying noun.Index
both aligns the method with existing index-finding methods (e.g. firstIndex(of:)
, lastIndex(where:)
) and provides type information about the result that isn't always present when working with concrete types. Point
, by contrast, doesn't appear elsewhere in generally used Swift APIs, except in reference to locations in a coordinate space.Feel free to start a thread in the discussion forums if you'd like to discuss the naming further.
Fine, I'll start a thread in the discussion forums. For the record, providing type information about the result that isn't always present when working with concrete types is a non-goal. If we were to do that we'd have to encode the return type in the name of every function whose return type was dependent on a generic parameter. This is not the same as "compensate for weak type information," because it's about the information that's available in the function signature. The signature (tools aggressively concretizing the information out of signatures notwithstanding) returns an Index
. The rest of this I'll deal with elsewhere.
IMO the port of the original Swift implementation made the name gratuitously worse. Aside from being precedented
partitionPoint
is shorter and more wieldy, not any easier to misinterpret, a natural name (it was chosen totally independently for the algorithm in C++) and doesn't make the type nameIndex
more significant than it should be. The addition ofing
in particular turns what can be read as a pure noun—a thing—into something that is definitely the noun form of a verb—an action—thus making this algorithm seem like it has something to do with partitioning when it does not.