# Is Implicit Tuple Splat behavior not fully removed?

**URL:** <https://forums.swift.org/t/is-implicit-tuple-splat-behavior-not-fully-removed/43129>\
**Category:** Using Swift\
**Created:** [December 19, 2020, 8:58pm UTC](https://forums.swift.org/t/is-implicit-tuple-splat-behavior-not-fully-removed/43129 "2020-12-19T20:58:14Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![DandyLyons](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/dandylyons/32/14417_2.png) [@DandyLyons](https://forums.swift.org/u/DandyLyons)\
**Post date:** [December 19, 2020, 8:58pm UTC](https://forums.swift.org/t/is-implicit-tuple-splat-behavior-not-fully-removed/43129/1 "2020-12-19T20:58:14Z")

</div>

So Swift 3 removed implicit tuple splat behavior. [See here](https://forums.swift.org/t/proposal-remove-implicit-tuple-splat-behavior-from-function-applications/1201)

So this would work pre-Swift 3 but now it no longer works:

```swift
func foo(x:Int, y:Int, z:Int) { }
let bar = (1, 2, 3)
foo(bar)

```

Meaning you can no longer pass a single tuple and have it automatically distribute into multiple parameters.

What I'm confused about is why does this work?

```swift
func call<I, O>(function: (I) -> O, params: I) -> O { return function(params)}
func sum(x:Int, y:Int, z:Int) -> Int {
    return x + y + z
}
let x = (1, 2, 3)
call(function: sum, params: x) //returns sum(x) which returns 6

```

Why does `call(function: sum, params: x)` compile but when I call `sum(x)` directly it doesn't compile?

Does Swift only ban **implicit** tuple splat behavior (but not explicit). Does Swift consider `call(function: sum, params: x)` to be **explicit** tuple splat? If so what is the difference between **implicit** and **explicit** here?

---

<div class="post-metadata">

**Author:** ![xwu](https://avatars.discourse-cdn.com/v4/letter/x/b487fb/32.png) [@xwu](https://forums.swift.org/u/xwu)\
**Post date:** [December 19, 2020, 9:09pm UTC](https://forums.swift.org/t/is-implicit-tuple-splat-behavior-not-fully-removed/43129/2 "2020-12-19T21:09:20Z")

</div>

> [@DandyLyons](#):
>
> What I'm confused about is why does this work?
> 
> ```swift
> func call<I, O>(function: (I) -> O, params: I) -> O { return function(params)}
> func sum(x:Int, y:Int, z:Int) -> Int {
> return x + y + z
> }
> let x = (1, 2, 3)
> call(function: sum, params: x) //returns sum(x) which returns 6
> 
> ```
> 
> Why does `call(function: sum, params: x)` compile but when I call `sum(x)` directly it doesn't compile?

You are correct: this behavior is an implicit splat and was removed.

However, this was found to cause an unacceptable usability regression, so an exception was made:

> [@\[Core team\] Addressing the SE-0110 usability regression in Swift 4](https://forums.swift.org/t/core-team-addressing-the-se-0110-usability-regression-in-swift-4/6147):
>
> Hello Swift community, Swift 3’s SE-0110 \<[https://github.com/apple/swift-evolution/blob/master/proposals/0110-distingish-single-tuple-arg.md&gt](https://github.com/apple/swift-evolution/blob/master/proposals/0110-distingish-single-tuple-arg.md&gt); eliminated the equivalence between function types that accept a single type and function types that take multiple arguments. However, for various implementation reasons \<[https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170612/037560.html&gt;](https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170612/037560.html&gt;), the implementation of SE-0110 (as well as the elimination of tuple “splat” behavior in SE-0029 \<[h…](https://github.com/apple/swift-evolution/blob/master/proposals/0029-remove-implicit-tuple-splat.md&gt;%5C)

---

<div class="post-metadata">

**Author:** ![DandyLyons](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/dandylyons/32/14417_2.png) [@DandyLyons](https://forums.swift.org/u/DandyLyons)\
**Post date:** [December 19, 2020, 9:18pm UTC](https://forums.swift.org/t/is-implicit-tuple-splat-behavior-not-fully-removed/43129/3 "2020-12-19T21:18:29Z")

</div>

Thank you Xiaodi.

Personally, I prefer this. Tuple splat behavior seems very powerful (though I can understand why they wanted it to be removed, it can definitely be abused). So it's nice that tuple splat behavior is still available, but not available directly. (It just feels really hacky to use it indirectly like this.)

---

<div class="post-metadata">

**Author:** ![Jens](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jens/32/12903_2.png) [@Jens](https://forums.swift.org/u/Jens)\
**Post date:** [December 19, 2020, 9:53pm UTC](https://forums.swift.org/t/is-implicit-tuple-splat-behavior-not-fully-removed/43129/4 "2020-12-19T21:53:24Z")

</div>

> [@DandyLyons](#):
>
> What I'm confused about is why does this work?

Because:

> [@Fixing the type system](https://forums.swift.org/t/fixing-the-type-system/33571/6):
>
> The type checker has an explicit rule that a function of multiple arguments can be converted to a function of one argument taking a tuple argument.

---

<div class="post-metadata">

**Author:** ![anon9791410](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@anon9791410](https://forums.swift.org/u/anon9791410)\
**Post date:** [December 20, 2020, 12:15pm UTC](https://forums.swift.org/t/is-implicit-tuple-splat-behavior-not-fully-removed/43129/5 "2020-12-20T12:15:27Z")

</div>

It is rather super powerful, actually. Consider the common use case:

```swift
let x = ((((((((((((((((((((1, 2, 3))))))))))))))))))))
call(function: (((((sum))))), params: ((((x)))))

```

Compiles fine, as we all need.

---

<div class="post-metadata">

**Author:** ![Lantua](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lantua/32/8868_2.png) [@Lantua](https://forums.swift.org/u/Lantua)\
**Post date:** [December 20, 2020, 12:18pm UTC](https://forums.swift.org/t/is-implicit-tuple-splat-behavior-not-fully-removed/43129/6 "2020-12-20T12:18:51Z")

</div>

> [@anon9791410](#):
>
> `((((((((((((((((((((1, 2, 3))))))))))))))))))))`

"common" 🤔🤔🤔.

---

<div class="post-metadata">

**Author:** ![Chris\_Lattner3](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/chris_lattner3/32/348_2.png) [@Chris\_Lattner3](https://forums.swift.org/u/Chris_Lattner3)\
**Post date:** [December 20, 2020, 5:03pm UTC](https://forums.swift.org/t/is-implicit-tuple-splat-behavior-not-fully-removed/43129/7 "2020-12-20T17:03:42Z")

</div>

That's is one of the most common concerns I hear from Swift programmers, they get [lost in a sea of parentheses](https://wiki.c2.com/?LostInaSeaofParentheses). We clearly need to put a stop to this ;-)

-Chris

---

<div class="post-metadata">

**Author:** ![Nickolas\_Pohilets](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/nickolas_pohilets/32/10659_2.png) [@Nickolas\_Pohilets](https://forums.swift.org/u/Nickolas_Pohilets)\
**Post date:** [December 21, 2020, 3:52pm UTC](https://forums.swift.org/t/is-implicit-tuple-splat-behavior-not-fully-removed/43129/8 "2020-12-21T15:52:06Z")

</div>

I’m not sure extra parentheses in this example do anything from the type system perspective. If I recall correctly, `(x)` is parsed as parenthesis expression, not a tuple literal. And single-element tuples are not possible in Swift.

---

<div class="post-metadata">

**Author:** ![anon9791410](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@anon9791410](https://forums.swift.org/u/anon9791410)\
**Post date:** [December 21, 2020, 5:59pm UTC](https://forums.swift.org/t/is-implicit-tuple-splat-behavior-not-fully-removed/43129/9 "2020-12-21T17:59:56Z")

</div>

> [@Nickolas\_Pohilets](#):
>
> If I recall correctly, `(x)` is parsed as parenthesis expression, not a tuple literal.

It's usable as such, but like the topic of this thread, how it actually works is confusing and unexplained by documentation.

 ![Screen Shot 2020-12-21 at 1.04.20 PM](https://global.discourse-cdn.com/swift/original/2X/9/9df46dc529ceb303a980fb3aedf6f1007b3d8f30.png)

> [@Nickolas\_Pohilets](#):
>
> And single-element tuples are not possible in Swift.

[For the most part. 😸](https://forums.swift.org/t/how-do-you-get-labeled-associated-values-from-mirror-children/36377)

---

<div class="post-metadata">

**Author:** ![DandyLyons](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/dandylyons/32/14417_2.png) [@DandyLyons](https://forums.swift.org/u/DandyLyons)\
**Post date:** [December 22, 2020, 8:37am UTC](https://forums.swift.org/t/is-implicit-tuple-splat-behavior-not-fully-removed/43129/10 "2020-12-22T08:37:46Z")

</div>

Just to clarify: Since an exception was made, is tuple splat behavior considered “deprecated”. Is it something we should never use and they were planning on completely banning it, but they postponed it because it broke too much code and they had other higher priorities to implement.

Or are they partially reversing their decision and saying this one exception is an area where tuple splat behavior is acceptable?

Basically I’m just trying to figure out what best practices are. Are we supposed to stay away from all tuple splat or just most?
