While I know it might be a bit strange to have different rules for each side, I 
think I prefer empty brackets on the left and Void on the right, but in 
combination with required parenthesis on the left. So we’d have:

        () -> Void              // yes
        Void -> ()              // no
        () -> ()                // no (rhs interpreted as empty tuple which is 
not allowed)
        () -> Int               // yes
        Int -> Void     // no (lhs no parens)
        (Int) -> Void   // yes

I think the parenthesis helps to highlight that it’s a function/closure, I 
think it’s also clearer for cases like:

        ((Int, String)) -> Void // this is a closure taking a two-part tuple
        (Int, String) -> Void           // this is definitely a closure taking 
an Int and a String

> On 23 Apr 2016, at 11:47, Антон Жилин via swift-evolution 
> <[email protected]> wrote:
> 
> Therefore the impermissible:
> (()) -> () Is identical to:
> (Void) -> () So to follow these rules, it must instead be:
> Void -> () … and we’re back to T1 -> T2 : )
> 
> Wrong! If we enforce parentheses in function types, we won't be able to write
> Void -> ()
> Parentheses will be required on the grammar level. The correct way to write 
> this will be:
> () -> ()  or  () -> Void
> The following will be legal:
> (Void) -> ()  and  (()) -> ()
> It is a function that takes a single parameter () and returns ().
> I additionally propose that the following should be illegal, because 
> additional parentheses aren't needed there:
> ((())) -> ()  and  () -> (())  and just (Int) and (())
> Hope it cleared up things a little bit.
> - Anton
> _______________________________________________
> swift-evolution mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to