[swift-evolution] When to use argument labels (a new approach)
Jordan Rose
jordan_rose at apple.com
Thu Feb 4 16:18:21 CST 2016
> On Feb 4, 2016, at 7:46, plx via swift-evolution <swift-evolution at swift.org> wrote:
>
> Consider the following examples:
>
> // today:
> func rangeOfString(searchString: String, options mask: NSStringCompareOptions) -> NSRange
> func stringByTrimmingCharactersInSet(characterSet: NSCharacterSet) -> String
> func indexOf(element: Element) -> Index?
>
> // ideal tomorrow, i assume:
> func rangeOf(searchString: String, options: NSStringCompareOptions) -> NSRange
> func trimming(characterSet: NSCharacterSet) -> String
> func indexOf(element: Element) -> Index?
>
> …how do we (b) justify the lack of first-argument labels in that “ideal tomorrow” while still also (a) actually applying the sentence/clause rule?
>
> At least to my eyes, “a, range of b”, “a, trimming b”, and “a, index of b”, are questionable even as clauses, let alone as sentences.
>
"a, trimming b" seems totally fine as a noun phrase to me, along the lines of "my speech, cutting out the parts you don't like". The other two are I guess what you're calling "implicit get" cases; you could also look at them as "(in [receiver])", i.e. "range (in a) of b" and "index (in a) of b". I think that extends to other nouny methods like -tracksWithMediaType: – it's "tracks (in myLibrary) with media type 'wax cylinder'".
(I'm not proposing that we try to make the source code read like that. As long as we're minimizing ambiguity, maximizing clarity, etc, it doesn't matter if we're doing it the same way that English does.)
Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160204/7850e9cf/attachment.html>
More information about the swift-evolution
mailing list