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

Антон Жилин antonyzhilin at gmail.com
Fri Apr 22 03:12:31 CDT 2016


+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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160422/39df9a89/attachment.html>


More information about the swift-evolution mailing list