apple / swift-algorithms

Commonly used sequence and collection algorithms for Swift
Apache License 2.0
5.97k stars 443 forks source link

`partitioningIndex` is gratuitously different, and worse than, `partitionPoint`. #19

Closed dabrahams closed 4 years ago

dabrahams commented 4 years ago

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 name Index more significant than it should be. The addition of ing 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.

natecook1000 commented 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:

Feel free to start a thread in the discussion forums if you'd like to discuss the naming further.

dabrahams commented 4 years ago

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.