<div dir="ltr"><div>+1 (assuming the OP means making naming consistent)</div><div><br></div>This is one of the ugliest aspects of Swift. There has to be some other way to ensure compatibility with Obj-C. This is particularly cruel to beginners, who won't understand why they can't write arguments the same way everywhere. It's also additional complexity for anyone reading a function.<div><br></div><div>My personal preference is that <b>*all*</b> arguments, not just regardless of position, but also regardless of their being in an init/method, have explicit labels by default. If one wants to override that with "_", one can do so, but it ought to work the same way everywhere.</div><div><br></div><div> </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 21, 2016 at 11:25 AM, Tony Parker via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi David,<div><br></div><div>This is obviously a topic which gets a lot of discussion, and I doubt I’ll be able to thoroughly convince anyone with an email or two on the topic… but I would like to share one of the reasons behind the decision to avoid labeling the first argument.</div><div><br></div><div>We surveyed the entire surface area of the iOS and OS X SDKs, looking to see how many arguments typical methods had. We found that the vast majority of methods actually have just one argument. If we went with a rule that first arguments should be named, then methods like:</div><div><br></div><div>sayMessage(“hello”)</div><div><br></div><div>would be this instead:</div><div><br></div><div>say(message: “hello”)</div><div><br></div><div>which isn’t really much of an improvement, in my mind.</div><div><br></div><div>Furthermore, when methods have more than one argument, we found that the additional arguments are most often modifiers or minor adjustments to the first argument. Or, put another way: when there are multiple arguments, the first argument is almost always far more important to the meaning of the method. Your example below follows this pattern as well: the primary purpose of the function is to say a message. The number of times it is said is a secondary modifier to the central purpose.</div><div><br></div><div>These factors led us to the conclusion that the label of the first argument is (in the vast majority of cases) really <i>part of</i> the method and not equal in importance to the remaining labels.</div><div><br></div><div>- Tony</div><div><br></div><div><br><div><blockquote type="cite"><span class=""><div>On Jan 21, 2016, at 9:23 AM, David Owens II via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br></span><div><div><div class="h5"><div style="word-wrap:break-word">Ok, this is something that's bugged me since Swift was released. It was <i>almost</i> fixed it back in the 1.x days (I think that was when it changed to be a bit more consistent between top-level funcs and members funcs).<div><br></div><div>The question is this, why do we still implicitly have unnamed first parameters for non-init functions, and in some cases, suggest putting the name of the first parameter in the name of the function? </div><div><br></div><div><font face="Menlo"> func say(message: String, times: Int) { ... } // or</font></div><div><font face="Menlo"> func sayMessage(message: String, times: Int) { ... }</font></div><div><font face="Menlo"><br></font></div><div><font face="Menlo"> say("hello world", times: 5) // or</font></div><div><font face="Menlo"> sayMessage("hello world", times: 5)</font></div><div><font face="Menlo"><br></font></div><div><font face="Menlo"> // vs.</font></div><div><font face="Menlo"><br></font></div><div><font face="Menlo"> say(message: "hello world", times: 5)</font></div><div><br></div><div>Let me be clear, I completely understand why the _ is supported, and I understand that it's not feasible to implicitly convert all the ObjC interfaces to move the parameter name into the first position (though they could be annotated to do this...).</div><div><br></div><div>However, why are we continuing that tradition with _new_ Swift APIs? There seems to be a perfectly good spot for the first parameter name of a function: the first parameter slot.</div><div><br></div><div>The seemingly poor choice of this shows up in other places too, like Doug Gregor's <i>Naming Functions with Arguments Labels</i> proposal. The default for that is to always have the _ in the first name slot.</div><div><br></div><div><div><font face="Menlo"> say(_:times:)</font></div></div><div><font face="Menlo"> sayMessage(_:times:)</font></div><div><font face="Menlo"><br></font></div><div><font face="Menlo"> // vs.</font></div><div><font face="Menlo"><br></font></div><div><font face="Menlo"> say(message:times:)</font></div><div><br></div><div>The other unfortunate thing about this, is that this is another instance where "init" behaves differently then the rest of Swift. I think it would be great to unify this.</div><div><br></div><div>Am I just missing the really compelling rationale for this?</div><div><br></div><div>Thanks,</div><div>David</div></div></div></div><span class="">_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></span></div></blockquote></div><br></div></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>