Skip to content

Record SE-110 as implemented in its current state #1121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion proposals/0110-distingish-single-tuple-arg.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
* Proposal: [SE-0110](0110-distingish-single-tuple-arg.md)
* Authors: Vladimir S., [Austin Zheng](https://github.com/austinzheng)
* Review Manager: [Chris Lattner](https://github.com/lattner)
* Status: **Accepted**
* Status: **Implemented**
* Decision Notes: [Rationale](https://lists.swift.org/pipermail/swift-evolution-announce/2016-July/000215.html), [Additional Commentary](https://lists.swift.org/pipermail/swift-evolution-announce/2017-June/000386.html)
* Bug: [SR-2008](https://bugs.swift.org/browse/SR-2008)
* Previous Revision: [Originally Accepted Proposal](https://github.com/apple/swift-evolution/blob/9e44932452e1daead98f2bc2e58711eb489e9751/proposals/0110-distingish-single-tuple-arg.md)

## Introduction

Expand Down Expand Up @@ -47,10 +48,23 @@ We propose that this behavior should be fixed in the following ways:

We understand that this may be a departure from the current convention that a set of parentheses enclosing a single object are considered semantically meaningless, but it is the most natural way to differentiate between the two situations described above and would be a clearly-delineated one-time-only exception.

Existing Swift code widely takes advantage of the ability to pass a multi-parameter closure or function value to a higher-order function that operates on tuples, particularly with collection operations:

```
zip([1, 2, 3], [3, 2, 1]).filter(<) // => [(1, 3)]
zip([1, 2, 3], [3, 2, 1]).map(+) // => [4, 4, 4]
```

Without the implicit conversion, this requires invasive changes to explicitly destructure the tuple argument. In order to gain most of the type system benefits of distinguishing single-tuple-argument functions from multiple-argument functions, while maintaining the fluidity of functional code like the above, arguments of type `(T, U, ...) -> V` in call expressions are allowed to be converted to parameters of the corresponding single-tuple parameter type `((T, U, ...)) -> V`, so the two examples above will continue to be accepted.

## Impact on existing code

Minor changes to user code may be required if this proposal is accepted.

## Alternatives considered

Don't make this change.

## Revision history

The [original proposal as reviewed](https://github.com/apple/swift-evolution/blob/9e44932452e1daead98f2bc2e58711eb489e9751/proposals/0110-distingish-single-tuple-arg.md) did not include the special-case conversion from `(T, U, ...) -> V` to `((T, U, ...)) -> V` for function arguments. In response to community feedback, [this conversion was added](https://lists.swift.org/pipermail/swift-evolution-announce/2017-June/000386.html) as part of the Core Team's acceptance of the proposal.