[swift-evolution] [Pitch] Allow trailing argument labels

Patrick Pijnappel patrickpijnappel at gmail.com
Wed Feb 22 04:24:12 CST 2017

I'd like to discuss allowing a trailing 'argument label' without an actual

func adding(_ other: Self, reportingOverflow) -> … // Actual case in SE-104
where this came up
func tableView(_ tableView: UITableView, numberOfSections) -> Int //
Referenced as tableView(_:numberOfSections)

As illustrated above, the way we reference functions extends very naturally
to include these.

This would be very useful for several cases:
• Delegate methods, which currently all start with the same prefix, except
for some odd cases that really actually just needed a trailing argument
• Cases where the function is a more specialized version of one with the
same name, but can't use a flag because the return type is different (e.g.
reportingOverflow), or the extra flag check is just undesirable. The
standard library now uses some workarounds to achieve this (e.g. having a
trailing argument of type void).
• Function names that just work more naturally with some additional words
after the last argument. If we allow trailing argument labels, you can form
any sentence, rounding out the syntax.

Overall, I think this could be the final missing piece to complete Swift's
functions-as-sentences approach.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170222/8cc41661/attachment.html>

More information about the swift-evolution mailing list