[swift-evolution] [Review] SE-0005 Better Translation of Objective-C APIs Into Swift
dabrahams at apple.com
Thu Jan 28 01:00:42 CST 2016
on Wed Jan 27 2016, Rob Mayoff <swift-evolution at swift.org> wrote:
>> - func respondWith(data: Data)
>> + func respond(data data: Data)
>> This one is unusual. I don’t mind `respond(data: …)`, but generally
>> there’s a word to the right of “with”, and here the “with” was just to
>> imply the argument without naming it.
>> The original ObjC method name was “respondWithData:”. “Data” restates type
>> info, so SE-0023 stripped it off; this transformation makes it the first
>> argument label.
> Can I tell, at a call site, whether `respond(data: someData)` is responding
> with someData, or responding to someData?
> That is, can I tell whether someData is the response,
Yes, you can tell, in the same way that you know what role "hello" plays
> or instead is something from the request that the receiver will use to
> compute the response?
> If I see `respondWith(someData)` or `respondWith(data: someData)` or
> `respondWithData(someData)`, it's clear to me that someData is the
Heh, well to draw that conclusion you'd have to know somehow that in
*this* API, unlike in so many others, “with” was not just being used as
a vacuous connector to allow “data” to be appended to the basename of
the method without being grammatically jarring. While there are a few
APIs where that's the case, it seems the vast majority of “with” uses
are of the vacuous kind, so this might just end up needing annotation.
> while a hypothetical call `respondTo(someData)` would tell me that
> someData is the input to the response-computing algorithm.
> _______________________________________________ swift-evolution
> mailing list swift-evolution at swift.org
More information about the swift-evolution