[swift-evolution] [Discussion] Enforce argument labels on tuples

Adrian Zubarev adrian.zubarev at devandartist.com
Wed Apr 20 12:59:22 CDT 2016

That’s why I’d like to discuss this topic and hear all your feedback.

Do you think it might be possible to add some optional extra flag to the language to enforce argument labeling. Not only for tuples as I started the discussion with but also for argument labels on blocks/closures?


func foo(tuple: (a: Int, b: Int)) { /* do some work */ }

// this will only work with

let test1 = (a: 1, b: 2)

func foo(block: (boo: Int) -> Void) { /* pass boo to block */ }

foo() { boo in // do is enforced here
	/* do some work*/

// or

foo() { (boo: Int) -> Void in
	/* do some work*/

An extra flag won’t break any codebase and as an addition will allow some good looking syntax at some places.

Adrian Zubarev

Am 20. April 2016 bei 19:47:03, Tino Heth (2th at gmx.de) schrieb:

I think it's good that the labels aren't enforced:  
This would sacrifice flexibility, and force us to write unnecessary boilerplate to "translate" labels (one library might use (height, width), and another (h, w) to express the same concept…)  

But: Objective-C had no tuples, so a final decision shouldn't happen until there is an agreement on best-practices for them...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160420/2bec431f/attachment.html>

More information about the swift-evolution mailing list