Re: [swift-evolution] [Pitch] Tuple Destructuring in Parameter Lists

2016-05-31 Thread Chris Lattner via swift-evolution
> On May 30, 2016, at 3:09 PM, Erica Sadun wrote: > You can't splat but you can decompose a tuple by assignment: Right. That is because assignment permits destructuring. Parameter lists do not (anymore). -Chris ___ swift-evolution mailing list swif

Re: [swift-evolution] [Pitch] Tuple Destructuring in Parameter Lists

2016-05-30 Thread Callionica (Swift) via swift-evolution
This is an interesting proposal, but I think splatting like Python would be preferable: creators of functions use separate parameters and callers can expand tuples as necessary by prefixing a tuple at point of use with * to expand it into separate arguments. Even with the Swift language as it is t

Re: [swift-evolution] [Pitch] Tuple Destructuring in Parameter Lists

2016-05-30 Thread Erica Sadun via swift-evolution
> On May 30, 2016, at 2:39 PM, Chris Lattner via swift-evolution > wrote: > >> On May 30, 2016, at 6:01 AM, Brent Royal-Gordon via swift-evolution >> wrote: >> >> // Proposed syntax: >> func takes(a (valueA, valueB): (Int, Int)) { >> // use valueA >> // use valueB >> } > > FWIW, Swift 1 sup

Re: [swift-evolution] [Pitch] Tuple Destructuring in Parameter Lists

2016-05-30 Thread Chris Lattner via swift-evolution
> On May 30, 2016, at 6:01 AM, Brent Royal-Gordon via swift-evolution > wrote: > > // Proposed syntax: > func takes(a (valueA, valueB): (Int, Int)) { > // use valueA > // use valueB > } FWIW, Swift 1 supported tuple destructuring in parameter lists, and we took it out to simplify the languag

Re: [swift-evolution] [Pitch] Tuple Destructuring in Parameter Lists

2016-05-30 Thread Dennis Weissmann via swift-evolution
> I like the idea of allowing destructuring everywhere we bind a name very > much. My only (minor) concern with doing this for tuples right now is that > it might encourage overuse of them where a struct would be a better choice. > > I have been thinking about destructuring of structs and cl

Re: [swift-evolution] [Pitch] Tuple Destructuring in Parameter Lists

2016-05-30 Thread Dennis Weissmann via swift-evolution
Great catch! I didn’t know that was possible! I’ll add it to the proposal. Thanks! - Dennis > On May 30, 2016, at 3:53 PM, Vladimir.S wrote: > > I believe you should add currently available syntax to proposal text: > > let c = zip(a,b).reduce(0) { (acc, tuple: (a: Int, b: Int)) in > acc + tu

Re: [swift-evolution] [Pitch] Tuple Destructuring in Parameter Lists

2016-05-30 Thread Dennis Weissmann via swift-evolution
Hi Brent, Thanks! Those are great points! I haven’t thought about the possibility of suppressing the external label. I like your option 2 very much! I’ll add it to the proposal and change the used variable names. - Dennis > On May 30, 2016, at 3:01 PM, Brent Royal-Gordon > wrote: > >> //

Re: [swift-evolution] [Pitch] Tuple Destructuring in Parameter Lists

2016-05-30 Thread Matthew Johnson via swift-evolution
Sent from my iPad On May 30, 2016, at 8:01 AM, Brent Royal-Gordon via swift-evolution wrote: >> // Allowed today: >> func takesATuple(tuple: (Int, Int)) { >> let valueA = tuple.0 >> let valueB = tuple.1 >> // ... >> } >> >> // Proposed syntax: >> func takesATuple(tuple (valueA, valueB): (

Re: [swift-evolution] [Pitch] Tuple Destructuring in Parameter Lists

2016-05-30 Thread Vladimir.S via swift-evolution
I believe you should add currently available syntax to proposal text: let c = zip(a,b).reduce(0) { (acc, tuple: (a: Int, b: Int)) in acc + tuple.a + tuple.b } func takesATuple(tuple : (valueA: Int, valueB: Int)) { print("a: \(tuple.valueA) b:\(tuple.valueB)") } Not so nice as proposed, but

Re: [swift-evolution] [Pitch] Tuple Destructuring in Parameter Lists

2016-05-30 Thread Brent Royal-Gordon via swift-evolution
> // Allowed today: > func takesATuple(tuple: (Int, Int)) { > let valueA = tuple.0 > let valueB = tuple.1 > // ... > } > > // Proposed syntax: > func takesATuple(tuple (valueA, valueB): (Int, Int)) { > // use valueA > // use valueB > } Personally, I find this example confusing because t

Re: [swift-evolution] [Pitch] Tuple Destructuring in Parameter Lists

2016-05-29 Thread Dennis Weissmann via swift-evolution
Thanks for everyone participating in this discussion! :) I’ve drafted a formal proposal, it is available here: https://github.com/dennisweissmann/swift-evolution/blob/tuple-destructuring/proposals/-tuple-destructuring.md Please let me know what you think (it would be great if a native speaker

Re: [swift-evolution] [Pitch] Tuple Destructuring in Parameter Lists

2016-05-11 Thread Dennis Weissmann via swift-evolution
Thanks for all your feedback! This is the current statistic: Closure syntax: All positive Function syntax: 3 (or 4) positive, 2 negative I’ll try to address the concern Geordie and T.J. have. > func takesATuple(someInt: Int, tuple: (valueA: String, valueB: String)) {} > It’s true that you still

Re: [swift-evolution] [Pitch] Tuple Destructuring in Parameter Lists

2016-05-08 Thread Geordie J via swift-evolution
Comments below > Am 05.05.2016 um 20:22 schrieb Dennis Weissmann via swift-evolution > : > > Following a short discussion with positive feedback on > [swift-users](http://thread.gmane.org/gmane.comp.lang.swift.user/1812 > ) I’d like to

Re: [swift-evolution] [Pitch] Tuple Destructuring in Parameter Lists

2016-05-06 Thread Gmail via swift-evolution
+1 I’ve tried to write parameter lists like `acc, (valueA, valueB) in` in the past, expecting it to work like this > On 05 May 2016, at 20:22, Dennis Weissmann via swift-evolution > wrote: > > Following a short discussion with positive feedback on > [swift-users](http://thread.gmane.org/gmane

Re: [swift-evolution] [Pitch] Tuple Destructuring in Parameter Lists

2016-05-06 Thread Cole Campbell via swift-evolution
+1 from me as well. I have no problem with the function declaration in the example. It's very intuitive and is much more elegant than destructing in the function body. Cole > On May 6, 2016, at 2:05 AM, Goffredo Marocchi via swift-evolution > wrote: > > +1 it improves readability a lot and t

Re: [swift-evolution] [Pitch] Tuple Destructuring in Parameter Lists

2016-05-06 Thread Goffredo Marocchi via swift-evolution
+1 it improves readability a lot and thus should be encouraged. [[iOS messageWithData:ideas] broadcast] > On 6 May 2016, at 07:57, Thorsten Seitz via swift-evolution > wrote: > > +1 > > I do like the syntax suggested by Dennis. Making use of Swift's ability to > differentiate between externa

Re: [swift-evolution] [Pitch] Tuple Destructuring in Parameter Lists

2016-05-05 Thread Thorsten Seitz via swift-evolution
+1 I do like the syntax suggested by Dennis. Making use of Swift's ability to differentiate between external and internal parameter names is a great idea! -Thorsten Am 06. Mai 2016 um 06:25 schrieb "T.J. Usiyan via swift-evolution" : +1  I have wanted this since the first beta. I had

Re: [swift-evolution] [Pitch] Tuple Destructuring in Parameter Lists

2016-05-05 Thread T.J. Usiyan via swift-evolution
+1 I have wanted this since the first beta. I hadn't proposed because I haven't come up with a nice syntax to do this in functions/methods. I don't particularly like func takesATuple(someInt: Int, tuple (valueA, valueB): (String, String)) and the closes that I have come is to simply reuse the

[swift-evolution] [Pitch] Tuple Destructuring in Parameter Lists

2016-05-05 Thread Dennis Weissmann via swift-evolution
Following a short discussion with positive feedback on [swift-users](http://thread.gmane.org/gmane.comp.lang.swift.user/1812) I’d like to discuss the following: Tuples should be destructible into their components in parameter lists. Consider the following code: let a = [0,1,2,3,4,5,6,7,8,9] le