[swift-evolution] named parameters - why hidden first?/proposal interest

Haravikk swift-evolution at haravikk.com
Sun Jan 24 05:30:22 CST 2016

> On 24 Jan 2016, at 10:34, Rudolf Adamkovic via swift-evolution <swift-evolution at swift.org> wrote:
> With our current Objective-C style, we need to repeat at least one word and often need to include "with", "by", "using", etc. to make it read nicely.
> Compare:
> 1.
> splitWithSeparator(_ separator: ...
> 2.
> split(separator: ...
> The first form repeats "separator" twice and needs "with". And then there's (as you mentioned) the underscore and the space character. In short, tons of crap.
> R+
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
Why not use split(withSeparator separator) instead?

The external parameter name still completes the natural language style, while allowing other split functions to be grouped together under a single action name (split). Personally I think is the best of both, in essence when you’re using the function/method you’re defining the action you want (split) then how you want to do it (withSeparator) which seems nice and logical.

- Haravikk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160124/759abba2/attachment.html>

More information about the swift-evolution mailing list