on Wed Apr 13 2016, Tony Parker <[email protected]> wrote: >> On Apr 13, 2016, at 12:57 PM, Dave Abrahams via swift-evolution >> <[email protected]> wrote: >> >> >> on Wed Apr 13 2016, Dave Abrahams <[email protected]> wrote: >> > >>>> Reverse is the best opposite we have of advance, so it makes sense to >>>> me. >>> >>> Oh, I get it. >>> >>>> Or we could use retreat. =) There are other pairs of words that work >>>> as well, like “increment/decrement”. >>> >>> Yeah, unfortunately those carry an incorrect implication when the >>> indices are numbers, because, e.g. the collection might be offsetting >>> the number by 2 for each position. One could of course argue that using >>> numbers that way as indices was a bad design choice. >>> >>> I'll have to think about that idea again. We considered and rejected it >>> for a reason, but it might not be a really strong one. Thanks for >>> bringing it up. >> >> ...and having talked it over at lunch, now I remember why we rejected >> it: there's no good way to make a nonmutating version. >> >> let x = c.incremented(i) // reads like an assertion about the past >> let y = c.incrementing(i) // reads like it has side-effects and returns c, >> or >> // a new version of c >> > > In fact, it does return a new version* of c; just like this: > > let s2 = myString.appending(“foo”) > > *new version: the result is related to the argument
Uhh, that is *really* stretching the concept of “new version.” By that logic, every method that returns non-void is returning a new version of the receiver. > > > This works out great: > > let next = c.incrementing(first) > c.increment(&next) It only works great if we give up the idea that there's supposed to be some correspondence between how adding “ing” affects meaning in English and how it affects meaning in our APIs. If I say to you, “give me your coat, emptying the pockets,” I expect to get a modified version of your coat, not of what's in the pocket. -- Dave _______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
