[swift-evolution] Issues with 0005-Better Translation of Objective-C APIs Into Swift
dabrahams at apple.com
Wed Feb 3 10:57:14 CST 2016
on Wed Feb 03 2016, Gwendal Roué <gwendal.roue-AT-gmail.com> wrote:
>> Le 3 févr. 2016 à 01:54, Dave Abrahams via swift-evolution
>> <swift-evolution at swift.org> a écrit :
>> on Tue Feb 02 2016, David Owens II <swift-evolution at swift.org> wrote:
>>>> On Feb 2, 2016, at 12:48 PM, Jarod Long via swift-evolution
>>>> <swift-evolution at swift.org> wrote:
>>>> This is definitely more clear when you completely separate these
>>>> lines from their context, but code isn't written or read in complete
>>>> isolation like this, so I think these examples significantly
>>>> exaggerate the ambiguity of the pattern in the real world.
>>>> Even if you only make the minor change of renaming p to proximity
>>>> (which is really what it should be), the first example becomes
>>>> pretty clear:
>>>>> let next = current.updating(proximity)
>>> I just want to comment on this as I keep seeing this for arguments on
>>> the lists. APIs themselves should not be relying on well named inputs
>>> into them to create clear API signatures.
>> I don't think *anybody* on this list believes they should.
>>> let content = listItemView.text.trimming(characters: .whitespaceAndNewlines)
>>> At least I have some context at the call site what the purpose of
>> 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?
> Precisely because of what you stated a few lines above : "I don't
> think *anybody* on this list believes [API] should [be relying on well
> named inputs »:
> let s: NSCharacterSet = .whitespaceAndNewlines
> let content = listItemView.text.trimming(s) // what?
That's not relying on well named inputs; it's relying on context, and
*that* is perfectly alright. We are never going to get to the point
that you can do without context in reading code. Proof: there's no
label for the receiver, yet you're not complaining. is
somehow perfectly clear when
More information about the swift-evolution