With the passing of WWDC and the beta release of macOS Catalina and iOS 13 we've discovered a disparity between Foundation's
NSOrderedCollectionDifference and Swift's
CollectionDifference APIs: the latter is missing
The rationale for the method's inclusion in Foundation was: after the initial version of collection diffing was feature complete it was soon obvious that a convenience for inverting a difference for use with e.g. an undo/redo stack was extremely useful.
The rationale for the method's omission from Swift was: I was busy and forgot to amend the proposal.
So, I've opened a PR for an amended proposal, and wanted to float this thread for people's reactions.
Before opening up the floor, I wanted to talk about naming.
Many many possibilities were considered when naming the Foundation API. Variants on
reversed were all considered.
undone were ultimately passed on the realization that they all can be used to describe the result of the action that the result is used for, and not the result itself.
inverse specifically wound up winning on the strength of its existing meaning in math; an inverse function produces the identity function when composed with its original. In terms of concrete diffs, composing a diff with its inverse produces an empty diff.