UPDATE Friday, June26th @ 10:49 PM
Yep… so I've tracked down the issue: http://www.openradar.me/21577729. The problem is that single parameter, generic functions are implicitly turning multiple parameters into a tuple. That's the root cause of the initial bug report.
Good times.
Here's the code if you want to try it out:
func f<T>(value: T) {
print("value: \(value)")
}
func f<T>(value: T, hi: Int) {
print("value: \(value) \(hi)")
}
f("hi")
f("hi", append: false)
f("hi", append: false, omg: "what?")
f("hi", hi: 12) // calls f(value: T, hi: Int)
f("hi", Hi: 12) // calls f(value: T)
UPDATE Friday, June 26th @ 10:02 PM
OK… so I totally screwed up… It's my fault, Swift is just fine (kind-of). (I still want print()
and println()
back though).
SO… it turns out I have a typo in my code below in my bug report rant…
for _ in 0 ..< titleWidth { print("━", appendNewLine: false) }
print("‚ïá", appendNewLine: false)
Should have been this…
for _ in 0 ..< titleWidth { print("━", appendNewline: false) }
print("‚ïá", appendNewline: false)
I'll let you spot the difference. I am unsure as to why I did not get a compiler error. The only reason I noticed the issue is because I tried to workaround the issue reported below by using another overload of print()
. That overload did correctly flag my labeling error. So, still a bug with print()
, but no where near as bad as I originally though below.
Also, in the playground, print("hi", whateverIWant: false)
works…
Anyhow, back to your regularly scheduled broadcast…
SHAME POST FOR ALL TO LEARN FROM…
I'm just going to copy my bug report here as I think this is worthy of being shared more broadly…
Bug Report First of all, I'm sure this bug has been logged before, but I don't care because this is so flipping irritating right now.
A "systems language" that has no proper ability to write console apps and output text to the screen succinctly is just broken. The move to replace print()
and println()
with a single function print()
with an overload – terrible decision.
Ok… breathe… I can deal, it's just an overloaded function now, no problem…
Imagine your surprise when you try and use it to print out some table headers:
for _ in 0 ..< titleWidth { print("━", appendNewLine: false) }
print("‚ïá", appendNewLine: false)
And you get output like this in the console:
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("━", false)
("‚ïá", false)
This is retarded and completely broken. Please change print()
back to the proper print()
and println()
versions and fix the implementation to actually output correctly to the screen.