[swift-evolution] [Proposal] Change infix operator attributes syntax to be more consistent with the rest of the language
Антон Жилин
antonyzhilin at gmail.com
Sun Mar 6 03:24:28 CST 2016
First of all, I suggest that we remove `assignment` from Swift 2.2 in any
case. It has been deprecated for long enough.
Operator declarations are always global.
Operator declarations of the same operator are always in conflict, even if
in different modules.
Therefore, I believe, operators would be best defined using directive
syntax:
#operator(<>, fixity: infix, associativity: left, precedence: 100)
#operator(!, fixity: postfix)
It's obvious from this declaration that it must be global and must not be
duplicated even in different modules (remember C macros?).
It would allow us to remove operator declaration grammar entirely, add a
directive instead. Simplification of grammar and consistency is one of
directions for Swift 2.2 and Swift 3.0.
Why not curly braces? Curly braces in Swift declarations are used to
declare multiple "child" entities. On the other hand, attributes and
directives are used with *preudo-arguments*.
I also want to remind the main difference between attributes and directives
in Swift. @-attributes always stand before something and modify it.
#-directives are stand-alone things on themselves.
- Anton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160306/22f9f2f7/attachment.html>
More information about the swift-evolution
mailing list