[swift-evolution] When to use argument labels (a new approach)
Jessy Catterwaul
mr.jessy at gmail.com
Wed Feb 3 17:42:41 CST 2016
The last example is more appropriate as a named subscript.
tracks[mediaType: .WaxCylinder, pianist: "Brahms"]
> On Feb 3, 2016, at 5:34 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
>
>
> on Wed Feb 03 2016, Matt Whiteside <swift-evolution at swift.org> wrote:
>
>> I have one comment (below) about this part:
>>
>>> On Feb 2, 2016, at 18:59, Paul Cantrell via swift-evolution
>>> <swift-evolution at swift.org> wrote:
>>>
>>> I have reservations about this. It doesn’t generalize perfectly well:
>>>
>>> a.tracksHavingMediaType("Wax Cylinder”, andPianist: “Brahms”)
>>>
>>> …strikes me as awkward compared to one of these:
>>>
>>> a.tracksHaving(mediaType: "Wax Cylinder”, pianist: “Brahms”)
>>> // or
>>> a.tracksMatchingCriteria(mediaType: "Wax Cylinder”, pianist: “Brahms”)
>>> // or even
>>> a.tracks(mediaType: "Wax Cylinder”, pianist: “Brahms”)
>>>
>>> …especially since, in a method of that form, _all_ the arguments are
>>> likely to have a default value of nil:
>>>
>>> a.tracks(mediaType: "Wax Cylinder”)
>>> a.tracks(pianist: “Brahms”)
>>
>> I prefer the original:
>>
>> a.tracksHavingMediaType("Wax Cylinder", andPianist: "Brahms”)
>>
>> to any of these,
>>
>> a.tracksHaving(mediaType: "Wax Cylinder", pianist: "Brahms")
>> // or
>> a.tracksMatchingCriteria(mediaType: "Wax Cylinder", pianist: "Brahms")
>> // or even
>> a.tracks(mediaType: "Wax Cylinder", pianist: "Brahms”)
>>
>> Because to me, the 3 alternatives, especially the last one, all read
>> more like hashmap accesses than method calls. In other words, they
>> make it appear as if you are passing in arbitrary keys to be queried,
>> rather than calling one specific method.
>
> I *think* I understand what you like and why you like it, but I can't
> say I understand your rationale. To test my understanding, what do you
> think of this:
>
> a.tracksHaving(mediaType: "Wax Cylinder", andPianist: "Brahms")
>
> ?
>
> Thanks,
>
> --
> -Dave
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160203/6de5bcb1/attachment.html>
More information about the swift-evolution
mailing list