Two days into my Swift (2) experience...
func X( a:Int, b:Int) {
print(a,b)
}
X( 1, 2) // error: missing argument label 'b:' in call
X(a:1, 2) // error: incorrect argument labels in call (have 'a:_:', expected '_:b:')
X( 1, b:2) // ok
X(a:1, b:2) // error: extraneous argument label 'a:' in call
Horror!
😢😮😠😕😟➖⚠✖
And I *never* use Emoji.
Contrast this with:
print( [1,2,3].contains(2) )
Perfect, I didn't know any of that syntax. But that's what I would expect. That's 'Pythonic'. Writing out my idea in straight pseudocode, and it works! Isn't that the goal of all of this? Getting the most natural effortless straightforward syntax?
That "named parameter mess" reminds me of C++, where everything breaks down into a zillion edge cases.
(On a side note, I wasted a lot of effort trying to get named parameters past the C++ committee. So there is some irony in the fact that although Swift has done it, it has in-so-doing created a C++-style awfulness).
I am making a bad smell here for a reason. Because I've watched the videos, I've read the book introduction. From my experience with C/ObjC/C++/C#/Python/JavaScript I love what's going on -- the idea of starting from scratch making a truly modern language with Pythonesque grace and C-like performance. The moment the opensource move hit of the news I jumped on it.
If I didn't think it was a great language I wouldn't complain. I would just silently walk away.
But we can't have fugliness like this.
All 4 of those cases should work. So that whether or not you supply a name for an argument is up to you.
drawCircle(position: myPosition, radius: myRadius) // BAD -- duplication is ugly
drawCircle(myPosition, myRadius, borderWidth:1) // GOOD
That's zen.
I'm sure there is some longwinded explanation for why the above catastrophe has happened. I'm not interested. I just want to see it gone. I want to teach this language to children.
I can see clearly the vision of Swift, and I am concerned the reality keeps to it.
π