[swift-evolution] [Discussion] Removing tuple labels from the type signature

Haravikk swift-evolution at haravikk.me
Fri Feb 5 03:12:33 CST 2016


> On 4 Feb 2016, at 23:26, Maximilian Hünenberger via swift-evolution <swift-evolution at swift.org> wrote:
> What disadvantage do I have if a conversion from (a: Int, b: Int) to (x: Int, y: Int) is allowed?

I think this is a good thing to keep for safety and to avoid errors; while a tuple may indeed contain the appropriate data its purpose may not be the same so using it accidentally could result in hard to diagnose bugs.

It’s better to be explicit in the code IMO, so it’s clear that a is in fact being used as x, and b as y.

Personally my preference would be to go in the opposite direction and disallow conversion of (a:Int, b:Int) to (Int, Int) for the same reasons, as it would force programmers to either add labels to the previously unlabelled tuple type, or make the conversion an explicit one to be certain that it’s being done in the correct order.


More information about the swift-evolution mailing list