> The point of this comparison is to point out that the anonymous type
> generating tuple is a) superfluous and b) a source of confusion and
> gratuitous complexity. It assumes the role at times of immutable arrays,
> anonymous structs, and immutable dictionaries depending on context and we
> already have all of those things.
There is another anonymous type — and it's very popular right now:
Closures*.
They are also a potential source of confusion (and even more complexity ;-), so
should they be removed as well?
I guess we'll keep both, but you are definitely right that there is much
complexity… but I'd rather improve that not by removing features, but by adding
more regularity:
There has been a discussion about anonymous enums as well, and if we could come
up with a syntax for anonymous reference types, imho everything would feel
simpler.
Most likely someone already mentioned this, but tuples can be used in
assignments in a way that isn't possible with any of the alternatives:
func tupleTest() -> (String, Int) {
return ("Foo", 10)
}
let (name, count) = tupleTest()
print("There are \(count) \(name)")
- Tino
* so there is yet another (odd) variant:
var cxy = { (c: Character) -> Int in
switch (c) {
case "x": return 1
case "y": return 2
default: fatalError()
}
}
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution