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

David Sweeris davesweeris at mac.com
Sat Jan 7 21:03:25 CST 2017

> On Jan 7, 2017, at 18:17, Freak Show via swift-evolution <swift-evolution at swift.org> wrote:
> It should also be noted that I am not a compiler or VM writer and I don't give a fig how the language does things at the implementation level and this is primarily a conceptual/syntactic proposal.
Conceptual/syntactic proposals do need to recognize implementation realities, though, regardless of how much fruit may or may not be involved.

> The goal is to make consuming data types predictable and simple and eliminate gratuitous complexity at the conceptual level through generalization of special cases.
Tuples can't use the "xyz[0]" syntax because the "[]" part is a function call which can only return a single type, but tuples can contain as many types as there are elements.

Array (and dictionaries) can't use the "xyz.0" syntax because the ".0" is essentially a property on the type, but those all need to be defined at compile-time which would make it impossible to grow or shrink them at run-time. (This restriction might go away if the proposal for variadic tuples goes through, but it hasn't happened yet.)

Anyway, these aren't "special cases" of the same general thing — they're fundamentally different operations.

As for tuples vs structs, there is some overlap, but not enough IMHO to justify getting rid of either. And structs can have unhelpful property names just as easily as tuples.

- Dave Sweeris.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170107/331eae1a/attachment.html>

More information about the swift-evolution mailing list