[swift-evolution] [Review] SE-0023 API Design Guidelines

Dave Abrahams dabrahams at apple.com
Fri Jan 22 17:17:47 CST 2016

on Fri Jan 22 2016, Joe Groff <swift-evolution at swift.org> wrote:

>       + When a mutating method is described by a verb, name its
>       non-mutating counterpart according to the “ed/ing” rule,
>       e.g. the non-mutating versions of x.sort() and x.append(y) are
>       x.sorted() and x.appending(y).
> This is a nice rule in theory, but English fights it with the full
> fury of its irregularity. There are a lot of common operations whose
> past tense shares a spelling with the infinitive—'split', 'cut',
> 'read', and 'cast' immediately come to mind. How do you handle naming
> non-mutating versions of these operations? Conjugating other irregular
> verbs also imposes a barrier on developers whose first language is not
> English.

Agreed.  There are also operations that are not naturally verbs.  That's
why we still haven't changed unionInPlace in SetAlgebraType, for
example.  The “InPlace” suffix convention is the best thing I've come up
with for handling these scenarios.


More information about the swift-evolution mailing list