[swift-evolution] [Pitch] Eliminate tuples - unify member access syntax

Tyler Cloutier cloutiertyler at aol.com
Mon Jan 9 02:38:36 CST 2017


I’ll tell you it, though, it would be really nice to be able to add functions to tuples, just as they are done with structs. 

Perhaps there is a way to formalize tuples as unnamed or anonymous Structs? It would make them going away strictly by making them more powerful.



> On Jan 8, 2017, at 12:35 PM, Tino Heth via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
>> 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
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170109/0a7c78d9/attachment.html>


More information about the swift-evolution mailing list