[swift-evolution] Issues with 0005-Better Translation of Objective-C APIs Into Swift

Kevin Schlei kevinschlei at gmail.com
Wed Feb 3 09:47:55 CST 2016


On Tue, Feb 2, 2016 at 7:59 PM, Dave Abrahams via swift-evolution <
swift-evolution at swift.org> wrote:

>
> on Tue Feb 02 2016, Jordan Rose <swift-evolution at swift.org> wrote:
>
> >> On Feb 2, 2016, at 17:28, David Owens II via swift-evolution
> >> <swift-evolution at swift.org> wrote:
> >>
> >>
> >>> On Feb 2, 2016, at 4:54 PM, Dave Abrahams via swift-evolution
> >
> >>> <swift-evolution at swift.org
> >>> <mailto:swift-evolution at swift.org>>
> >>> wrote:
> >>>
> >>>> Similarly,
> >>>>
> >>>> let content = listItemView.text.trimming(characters:
> .whitespaceAndNewlines)
> >>>>
> >>>> At least I have some context at the call site what the purpose of
> >>>> .whitespaceAndNewlines.
> >>>
> >>> You wouldn't say "go to the garden and trim the plant: rhododendrons".
> >>> It isn't necessary for comprehension.  Why do you feel characters: is
> >>> necessary here?
> >>
> >> Because unlike the English phrase, "trimming" does not have an
> >> implicit object set based on the context of a string; what else
> >> would you typically trim in a garden other than plant life? I could
> >> naturally create an API that allows trimming by a line range or
> >> string content, as an example.
> >>
> >> "public func foo() {}".trimmed(text: "public ")
> >> longContentWithKnownPreamble.trimmed(lines: 0..<5)
> >>
> >> We could make these different APIs as opposed to overloads, though
> >> I'm not convinced that they are not simply different ways to trim
> >> content.
> >
> > That's actually why this one is "trimming", not "trimmed". "trimming"
> > allows a direct object; "trimmed" does not.
> >
> > I don't really have a problem with this overload set, although
> > admittedly I can't tell if we're trimming prefixes, suffixes, or both,
> > and I would hope that's consistent between the two.
> >
> > inputText.trimming(.whitespaceAndNewlines)
> > inputText.trimming("public ")
> >
> > These are both perfectly good noun phrases in English, too: "[get me]
> > the inputText, trimming whitespace and newlines" and "[get me] the
> > inputText, trimming 'public '".
> >
> > (But to play David's Advocate, it also seems perfectly reasonable in
> > English to say "[get me] the inputText, trimming whitespace and
> > newline characters" and "[get me] the inputText, trimming the string
> > 'public '".)
>
> Back to Strunk & White.  Yes, people often use more words than
> necessary, so it sounds normal.  These two aren't so bad, but it's death
> by a thousand cuts.
> <https://lists.swift.org/mailman/listinfo/swift-evolution>
>

And now it'll be death by a thousand command-clicks. :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160203/896efd09/attachment.html>


More information about the swift-evolution mailing list