[swift-evolution] Proposal: Remove implicit tuple splat behavior from function applications
Chris Lattner
clattner at apple.com
Sun Jan 31 22:51:27 CST 2016
> On Jan 31, 2016, at 10:35 AM, Janosch Hildebrand <jnosh at jnosh.com> wrote:
>
> +1 to the existing proposal.
>
>
> On a related note, would this also affect the implicit "argument-list to tuple" conversion?
> To give an example:
>
> var array: [(Int, Int)] = []
> var int_var = 1
> let int_let = 1
>
> // These obviously work
> array.append((int_let, 1))
> array.append((1, 1))
> array.append((int_var, 1))
> array.append((int_var, int_var))
Yes, these should all work.
> // The following have worked to varying degrees over Swift's (public) lifetime
> // Currently only the first example compiles
> array.append(int_let, int_let)
it is a bug that this first one compiles, it is an example of the flakiness caused by this. This is the inverse of splat :-)
> array.append(int_let, 1)
> array.append(1, 1)
> array.append(int_var, 1)
> array.append(int_var, int_var)
These should all be uniformly rejected, since append takes one parameter.
> This is in a way the reverse of splatting but IMO equally troublesome at least in it's current form.
> And it also presumes some form of equivalence between function argument lists and tuples.
>
> So my question is does the proposal already cover removing this behaviour (in which case +1)?
Yes, even with the current design, this is a bug. As I mentioned, the tuple “splat” feature has a number of bugs.
-Chris
More information about the swift-evolution
mailing list