[swift-evolution] [Draft] Rename Sequence.elementsEqual
Xiaodi Wu
xiaodi.wu at gmail.com
Sat Oct 14 00:33:22 CDT 2017
On Fri, Oct 13, 2017 at 11:58 PM, Adam Kemp <adam.kemp at apple.com> wrote:
> > That the proposed name is obtuse is intentional--as Nate has
> surmised--as a way to prompt the unfamiliar user to look up the
> documentation.
>
> This is a strange philosophy for naming things. I see what you’re saying,
> but it feels very wrong to deliberately name something such that people
> will not understand it without documentation. I feel like we can do better
> than that.
That's not exactly the philosophy. The overarching desiderata are:
1. This method must be named in such a way that clearly conveys that it is
not plausibly a spelling for `==`. To my best estimation, users who
unintentionally use `elementsEqual` instead of `==` do so because they see
the former listed when they read the documentation but don't see the latter
(as operators suffer from various discoverability issues), and then they
think, "Swift designers must have decided to use this spelling as the
equivalent of `==` for arrays." By contrast, no one sees
`lexicographicallyPrecedes` and thinks, "Swift designers must have decided
to use this spelling as the equivalent of `<` for arrays!"
2. If a user is familiar with what a lexicographical comparison is, then
they should be able to (correctly) identify this method as of a kind
without going to the documentation. If a user is unfamiliar with what a
lexicographical comparison is, then they should not be misled by the method
name to think that it is something other than what it is; they need to read
the documentation and we do a good thing by alerting them to that need by a
carefully thought-out name--we are not thereby *creating* additional
demands to consult the documentation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171014/328ccaed/attachment.html>
More information about the swift-evolution
mailing list