[swift-evolution] Proposal: Always flatten the single element tuple

Daryle Walker darylew at mac.com
Thu Jun 8 16:29:42 CDT 2017


> On Jun 7, 2017, at 11:12 PM, Stephen Celis via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> On Jun 7, 2017, at 10:33 PM, Xiaodi Wu via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> However, what I don’t get is why you’d have a mismatch here. Your method `first` accepts a closure, and surely the type it expects should be `((String, Conversation)) -> Bool` instead, since that is the type that the `filter` method expects in the body of your implementation?
> 
> I must continue to ask for more justification as to why it's _so_ valuable to consider "(Int,Int)->()" and "((Int,Int))->()" to be different in _most_ cases. Even in the contrived-described example above, the function may be reusable and the engineer may pass "String" and "Conversation" objects directly in some cases, and this distinction only makes things more difficult and requires cumbersome workarounds.

Imagine if “(Int, Int)” was hidden behind a type-alias. You expect you’d be entering a single argument. But, surprise, you unintentionally activated the secret tuple-exploding mode and you’re actually passing in two arguments!

[I didn’t follow the original discussion, so apologies if using a type-alias doesn’t case tuple-explosion. Of course, that would be a different code smell….]

— 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com 



More information about the swift-evolution mailing list