[swift-evolution] [Review] SE-0110: Distinguish between single-tuple and multiple-argument function types

Duan daniel at duan.org
Tue Jul 5 18:27:54 CDT 2016


I have a patch that implements this proposal *except* this part. (aka () -> Void means 0 argument therefore { _ in } is a mismatch).

If we were to interpret tuple and the outer paren as described in this proposal, it should be consistent everywhere, therefore requires more consideration (separate proposal) and bigger change in the compiler.

Daniel Duan
Sent from my iPhone

> On Jul 5, 2016, at 2:07 PM, Jordan Rose <jordan_rose at apple.com> wrote:
> 
> 
>> On Jul 3, 2016, at 5:02, Vladimir.S via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> On 02.07.2016 4:20, Daniel Duan via swift-evolution wrote:
>>>> Vladimir.S via swift-evolution <swift-evolution at ...> writes:
>>> 
>>> Following your conclusion, should this be legal as well?
>>> 
>>> let f: () -> Void = { x in print(x) } // f() prints "()"
>>> let f: (Int) -> Void = { x in print(x) } // f(5) prints "5"
>>> 
>>> In other words, "0 argument" is an impossible scenario?
>> 
>> I don't see problems here. ()->Void means (Void)->Void, there *is* one parameter of Void type, which we can omitted as it is empty tuple. So, if you want you can write f(()) or or let z = (); f(z); or just f(), so in closure definition you can have one argument or can have 0 defined arguments if the only argument is of type Void.
> 
> I already said this on the bug you filed, but I disagree quite strongly with this interpretation, based on SE-0029. IMO, going from (()) to () is a form of tuple splat.
> 
> Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160705/45919b95/attachment.html>


More information about the swift-evolution mailing list