[swift-evolution] History and future of Swift's parentheses
Gor Gyolchanyan
gor at gyolchanyan.com
Fri Jun 9 12:17:31 CDT 2017
Yes, except why would you need to define `((A, B)) -> C`?, If you need to pass a 2-element tuple into a function that takes two parameters - you can! If you want to pass two values into a function that *looks* like it takes a single 2-element tuple - you can! Seems to me that the difference between `((A, B)) -> C` and `(A, B) -> C` is virtually non-existent. But keep in mind that this only works for bare tuples (the ones that can't have labels). Non-closure functions DO have labels, which is part of their signature, so this is a different story.
> On Jun 9, 2017, at 6:18 PM, Gwendal Roué <gwendal.roue at gmail.com> wrote:
>
>
>> Le 9 juin 2017 à 17:12, Gor Gyolchanyan via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> a écrit :
>>
>>>
>>> So I wonder if any of you have had any thoughts about what Swift's parentheses-related future (or evolutionary baggage) will be?
>>>
>>
>> I really wish swift used the concept of tuples **exclusively** for all purposes that involve parentheses, as well as dividing tuples into two categories:
>> - Bare tuples, which do not have labels.
>> - Rich tuples, which do.
>> As a consequence, here's a list of statements that would become true:
>> - All functions take exactly one parameter, which is a tuple.
>> - All closures (a.k.a. function pointers) take exactly one parameter, which is a bare tuple.
>> - All functions return exactly one parameter, which is a tuple.
>> - Pattern matching is done on a single bare tuple using a single bare tuple pattern.
>>
>> The currently ongoing proposal to make a single-element tuple auto-flatten would work extremely well with this idea, by making all these changes completely backward-compatible.
>
> If I have well understood, Swift has evolved away from this.
>
> If what you describe were true, added to the fact that there is no such thing as a one-element tuple in the language, then (A,B) -> C and ((A, B)) -> C could not be distinguished, for the simple reason that ((A, B)) -> C could not be defined.
>
> For ((A, B)) -> C to be defined, we'd need a function that takes exactly one parameter, which is a tuple (your idea), whose single element is a tuple (oops, there is no single-valued tuples).
>
> No opinion here, just they way I have understood recent Swift history.
> Gwendal
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170609/177b8d17/attachment.html>
More information about the swift-evolution
mailing list