instead of all these debates about teapots and deities how about we stop and think about what this means for the things we actually want to use them for.
I wrote a function that takes three arguments.
func foo1(a:Int, b:Int, c:Int)
Can I call it like this?
foo1(1, 2, 3) // currently doesn’t work
foo1((1, 2, 3)) // currently doesn’t work
foo1(a: 1, b: 2, c: 3) // ✅
foo1((a: 1, b: 2, c: 3)) // currently doesn’t work
I wrote a function that takes a single tuple argument with 3 elements.
func foo2(_ arg:(a:Int, b:Int, c:Int))
Can I call it like this?
foo2(1, 2, 3) // currently doesn’t work
foo2((1, 2, 3)) // ✅
foo2(a: 1, b: 2, c: 3) // currently doesn’t work
foo2((a: 1, b: 2, c: 3)) // ✅
What if the argument label is required at the call site?
func foo3(arg:(a:Int, b:Int, c:Int))
Can I call it like this?
foo3(arg: (1, 2, 3)) // ✅
foo3(arg: ((1, 2, 3))) // ✅
foo3(arg: (a: 1, b: 2, c: 3)) // ✅
foo3(arg: ((a: 1, b: 2, c: 3))) // ✅
Should this be allowed?
func foo4(arg:(a:Int)) // currently doesn’t work
Can I call it like this?
foo4(arg: 1) // according to foo3, this should work
foo4(arg: (1)) // according to foo3, this should work
foo4(arg: (a: 1)) // according to foo3, this should work
foo4(arg: ((a: 1))) // according to foo3, this should work
What about this?
func foo5(_ arg:(a:Int)) // currently doesn’t work
Can I call it like this?
foo5(1) // according to foo3, this should work. according to foo2, it shouldn’t
foo5((1)) // this should work, but doesn’t.
foo5(a: 1) // this shouldn’t work.
foo5((a: 1)) // this should work, but doesn’t.
Should this be allowed?
let a:Int = (b: 35) // currently doesn’t work
What about this?
let a:(b:Int) = (b: 35) // currently doesn’t work
If I have this:
let a:Int = 13
let b = a
what is the type of b? is it Int
or (a:Int
)?
If I have this:
let a = (c: 13)
let b = a
what is the type of b now? Int
, (a:Int
), or (c:Int)
?
I want to write a variadic vector addition function that can also take a scalar, so that I can add Int
s, (Int, Int)
s, (Int, Int, Int)
s, and so forth. Should I be able to do this?
I want to make the above function generic, so that I can add T
s, (T, T)
s, (T, T, T)
s, and so forth. Should I be able to do this?
I want to do the same thing as above, but allow T
itself to be a 3-tuple type. If I add two T
values, am I adding them as two 3-vectors, or two scalars?