I wonder what that is. I do not think it is possible without doing something as suggested by @marcoss. The problem is that you can drop the names in tuples:
let named_pair = (s: "hello", i: 1) named_pair.s // hello let anon_pair = named_pair as (String,Int) // or anon_pair: (String,Int) = named_pair, if you prefer anon_pair.s // no such member 's'
Now suppose you define two functions that are identical, except that one has named arguments:
func f(s: String, i: Int) { println("_: \(s)") } func f(#s: String, #i: Int) { println("s: \(s)") }
Then you can call it through tuples with named arguments vs unnamed:
f(named_pair) // prints s: hello f(anon_pair) // prints _: hello // but if you try to call a named argument function with unnamed tuples: func g(# s: String, # i: Int) { println("s: \(s)") } g(anon_pair) // compiler error let h = g h(anon_pair) // compiler error h(named_pair) // works
But since you can drop these names, you can do this:
// compiles and runs just fine... (g as (String,Int)->())(anon_pair) let k: (String,Int)->() = g // as does this k(anon_pair)
And this ability to do this means that you cannot use a type to disambiguate a function that is overloaded only with argument names, as far as I can tell.
source share