[swift-evolution] [pitch] Eliminate the "T1 -> T2" syntax, require "(T1) -> T2"

Vladimir.S svabox at gmail.com
Fri Apr 22 05:44:20 CDT 2016


IMO +1 for Антон's suggestion, but

"It will also eliminate situation when you can pass () argument to a () → T
function."

What do you think about the result "type":

typealias f1 = () -> Void
typealias f2 = () -> ((Void))
typealias f3 = () -> (())
typealias f4 = () -> ((((((()))))))

They are all equal definition now. In your opinion, should we change this 
also in some way?

On 22.04.2016 11:12, Антон Жилин via swift-evolution wrote:
> +1, but this proposal need further work.
> Specification of the new function grammar is needed.
>
> Currently, it looks like:
>
> function-type → type
> <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Types.html#//apple_ref/swift/grammar/type>­|throws­|_opt
> ­|->­|type
> <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Types.html#//apple_ref/swift/grammar/type>
>
> It is already false, because some attributes can only be used in function
> types.
>
> I suggest to rewrite it to something like:
>
> /function-type/ → |(| /function-parameter-types/_opt  |)| |->| /type/
>
> /function-type/ → |(| /function-parameter-types/_opt  |)| |throws| |->| /type/
>
> /function-type/ → |(| /function-parameter-types/_opt
>  |)| |rethrows| |->| /type/
>
> /function-parameter-types/ → /function-parameter-type/
>
> /function-parameter-types/ → /function-parameter-type/ |,| /function-parameter-types/
>
> /function-parameter-type/ → /function-parameter-attributes/ /type/
>
> It will also eliminate situation when you can pass () argument to a () → T
> function.
> Function types Void->T will need to be migrated.
>
> - Anton
>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>


More information about the swift-evolution mailing list