<div dir="ltr">I would think that the naming guidelines are an argument for reducing the role of argument labels, if any.<div><br></div><div>This labeled tuple makes sense, because 'x' and 'y' describe the semantic meaning of each element (Int which represents an x-coordinate):</div><div><br></div><div>let myTuple: (x: Int, y: Int)</div><div><br></div><div>This also makes sense, because 'hits' and 'runs' describe the semantic meaning of each argument (Int which represents number of hits):</div><div><br></div><div>let a : (hits: Int, runs: Int) -> Bool</div><div><br></div><div>This makes absolutely no sense to me:</div><div><br></div><div>let b: (ofHits: Int, forRuns: Int) -> Bool</div><div><br></div><div>In fact, 'b' is a better example than the average, because of the naming guideline point to spell out the semantics of weakly typed arguments in the argument label.</div><div><br></div><div>func getWidget(for provider: Provider, with manifest: ShippingManifest) -> Widget { /* ... */ }<br></div><div><br></div><div>let widgetGetter : (for: Provider, with: ShippingManifest) = getWidget</div><div><br></div><div>At this point, the labels are completely superfluous. They make no sense except in the context of a method name, because they are prepositional phrases. Knowing that the Provider is "for" something and something does something "with" the ShippingManifest is absolutely useless to anyone reading the code where the method name those labels are part of isn't immediately obvious.</div><div><br></div><div>Austin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 30, 2016 at 3:33 PM, Michael Ilseman 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"><br><div><span class=""><blockquote type="cite"><div>On Jun 30, 2016, at 11:43 AM, Scott James Remnant via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br><div><div>-1<br><br>This proposal doesn’t even use Swift naming style to make its point, as soon as you do, the reason why Swift considers argument labels to be part of the type signature becomes apparent. <br><br>The author of the proposal uses the following example:<br><br> func doSomething(x: Int, y: Int) -> Bool<br><br><br>This is just not Swift-y, a much better example would be:<br><br> func sinkBattleship(atX x: Int, y: Int) -> Bool<br><br></div></div></blockquote><div><br></div></span><div><pedanticism></div><div>If you want to talk about pedantic following of API naming guidelines for example code, then I believe that your example also runs afoul. It would be:</div><div><br></div><div>func sinkBattleshipAt(x: Int, y: Int) -> Bool</div><div><br></div><div>Due to a special case where the preposition covers multiple arguments. This arrises mostly from flatten-ed structs as parameters, e.g. from old C APIs predating struct literal syntax. See:</div><div><br></div><div><ul style="margin:1em 0px;padding:0px 0px 0px 40px;list-style-position:initial;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,Arial,Verdana,sans-serif;font-size:18px"><li style="margin:0px;padding:0px"><div style="max-height:1000rem"><p style="margin:0px 0px 1.5em;padding:0px">An exception arises when the first two arguments represent parts of a single abstraction.</p><div><pre style="margin:0.5em 0.5em 1.5em 10px;padding:0.5em 0.5em 0.5em 1em;font-size:14px;line-height:18px;border-left-width:3px;border-color:rgb(246,183,190);border-left-style:solid;overflow:visible;font-family:Menlo,Consolas,Monaco,'Courier New',monospace,serif;background-color:rgb(249,226,228)"><code style="font-size:1em;white-space:inherit;font-family:Menlo,Consolas,Monaco,'Courier New',monospace,serif">a.move(<strong>toX:</strong> b, <strong>y:</strong> c)
a.fade(<strong>fromRed:</strong> b, <strong>green:</strong> c, <strong>blue:</strong> d)
</code></pre></div><p style="margin:0px 0px 1.5em;padding:0px">In such cases, begin the argument label <em>after</em> the preposition, to keep the abstraction clear.</p><div><pre style="margin:0.5em 0.5em 1.5em 10px;padding:0.5em 0.5em 0.5em 1em;font-size:14px;line-height:18px;border-left-width:3px;border-color:rgb(192,255,188);border-left-style:solid;overflow:visible;font-family:Menlo,Consolas,Monaco,'Courier New',monospace,serif;background-color:rgb(230,255,229)"><code style="font-size:1em;white-space:inherit;font-family:Menlo,Consolas,Monaco,'Courier New',monospace,serif">a.moveTo(<strong>x:</strong> b, <strong>y:</strong> c)
a.fadeFrom(<strong>red:</strong> b, <strong>green:</strong> c, <strong>blue:</strong> d)
</code></pre></div></div></li></ul><div><font color="#333333" face="Helvetica Neue, Helvetica, Arial, Verdana, sans-serif" size="4"><br></font></div></div><div><div></pedanticism></div><div><br></div></div><span class=""><div><br></div><div><br></div><br><blockquote type="cite"><div><div>the proposal states that the argument labels be then stripped from the type, which would make this method type-compatible with:<br><br> func meetsBattingAverage(ofHits hits: Int, forRuns runs: Int) -> Bool<br><br><br>I don’t think it’s desirable for this to work at all… Argument labels are not parameter names, they are a first class part of Swift’s type system, and always meaningful when employed properly.<br><br><br>Scott<br>_______________________________________________<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></div></div></blockquote></span></div><br></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>