[swift-evolution] [Pitch] Eliminate tuples - unify member access syntax
David Sweeris
davesweeris at mac.com
Sun Jan 8 12:49:49 CST 2017
On Jan 8, 2017, at 09:33, Freak Show <freakshow42 at mac.com> wrote:
>> On Jan 7, 2017, at 22:51, David Sweeris <davesweeris at mac.com> wrote:
>
>> A really convenient way to pass around multiple values without having to bother with a formal struct.
>
> That's actually a big part of my concern.
>
> The people on this list are, I'm certain, among the top programmers working.
>
> I'm more worried about what happens when average (which IME means barely competent) developers get going with this. I suspect nobody will ever declare a struct again.
Doubtful, since tuples can't have any computed properties, functions, or conform to protocols.
> Type declarations are valuable - they are an opportunity to express intent. OTOH, a pair of ints is a pair of ints and if all pairs of ints are type compatible then opportunities for catching errors drop if developers start favoring anonymous tuples over former structs.
I don't think they are... "(Int, Int)" (without labels) will type-check to any pair of Ints, but IIRC "(x:Int, y:Int)" won't type-check to "(a:Int, b:Int)".
>> On Jan 7, 2017, at 23:37, Derrick Ho <wh1pch81n at gmail.com> wrote:
>>
>> I think pattern matching is the most compelling reason to keep tuples.
>>
>> If they were gone, how would we replace the following?
>>
>> switch (a, b) {
>> case (value1, value2):
>> case (value3, value4):
>> }
>
>
> I really have to ask. What do you use this for? In general iPhone application programming I have never wanted or needed to do that. I do some AudioUnits as well. Still never needed it.
"Need" is a strong word... Yeah, I could switch over the first value and then for every single case nest another switch over the second value, but that'd be annoying and obscure the underlying logic.
- Dave Sweeris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170108/ae7e85e3/attachment.html>
More information about the swift-evolution
mailing list