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

Gwendal Roué gwendal.roue at gmail.com
Wed Feb 3 04:10:58 CST 2016


> 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.
> 
> […]
> 
>> 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?

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?

Gwendal



More information about the swift-evolution mailing list