[swift-evolution] [Pitch] Make the first parameter in a function declaration follow the same rules as the others

Jordan Rose jordan_rose at apple.com
Fri Mar 11 16:57:34 CST 2016


> On Mar 11, 2016, at 13:30 , Dave Abrahams <dabrahams at apple.com> wrote:
> 
> 
>> On Mar 11, 2016, at 11:27 AM, Joe Groff <jgroff at apple.com <mailto:jgroff at apple.com>> wrote:
>> 
>>> 
>>> On Mar 11, 2016, at 11:20 AM, Jordan Rose via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> 
>>> 
>>>> On Mar 10, 2016, at 15:34 , Dave Abrahams via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>>> 
>>>> on Wed Mar 09 2016, Jordan Rose <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>>> 
>>>>> This is my concern too. Our guidelines often lead to the first
>>>>> parameter having a label, but usually that name isn't the same as the
>>>>> name of the parameter—one's a preposition, the other's a noun. I'm
>>>>> pretty sure the common case is still unlabeled. 
>>>> 
>>>> It's about 50/50 (slight edge to labeled first parameters) in the
>>>> imported Cocoa APIs.
>>> 
>>> If it's easy to get these numbers, how many of the first parameters have the same label as the parameter name?
>> 
>> If you're going to measure that, you should also measure it for second, third, ..., Nth parameters too for comparison.
> 
> Anyone who wants to measure is free to do so: simple regexps and wc generally work for this purpose.
> 
> https://github.com/apple/swift-3-api-guidelines-review/tree/swift-3/Platforms <https://github.com/apple/swift-3-api-guidelines-review/tree/swift-3/Platforms>
…in retrospect, probably more of the Cocoa names would match up if they had this shorthand before:

  func beginSheetModal(for window: NSWindow, modalDelegate delegate: AnyObject?, didEnd didEndSelector: Selector, contextInfo contextInfo: UnsafeMutablePointer<Void>)

- for/window is a true difference
- modalDelegate/delegate is just convenience inside the method; it could have easily been modalDelegate/modalDelegate
- didEnd/didEndSelector actually does match up in the original; the importer has (correctly) changed it to not match
- contextInfo/contextInfo is a match

So I'm not convinced results for the later parameters are meaningful. Haven't looked at first parameters yet.

Jordan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160311/dc2f31b3/attachment.html>


More information about the swift-evolution mailing list