Swift Operators - A Visual Reference
Mon Aug 04 2014
Xcode 6 Beta 4 was released with an updated reference manual (and iBook) that now includes the exact Unicode scalar ranges that are permissible as Swift operators. Unfortunately, I don't read straight Unicode scalar ranges so I thought I'd see what the ranges actually mapped out to.
The following are screenshots from OS X Mavericks' character helper dialog for all valid operator scalars in Swift. I've struck out (in red) any that aren't included.
As noted above and also by the EBNF in the The Swift Language: Lexical Structure, only certain Unicode scalars may be used as the
operator-head, which is to say - the first scalar of the operator must be of a strict subset of the scalars below. Conversely, both
operator-head scalars and
operator-character scalars may all be used for any scalar that follows the first.
operator-characterscalars are all Unicode combining scalars, and they have to appear second in a sequence to a non-combining Unicode scalar to make a valid Extended Grapheme Cluster. For more about Unicode scalars and combining marks, see The Swift Programming Language: Extended Grapheme Clusters.
In addition to this (something that I won't go into in this post), Swift operators may also take the form of a
dot-operator, which is prefixed by two dots (..) and may be followed by more dots (.) and/or any
operator-character (that includes any
operator-head). It likely that's how the
..< operators have been defined.
Apologies for the missing glyphs in the diagrams. I'm writing this as a quick reference for the beta but I'm sure I or someone else will create a far better tool for 1.0.
(U+00A1–U+00A7, U+00A9 or U+00AB, U+00AC or U+00AE, U+00B0–U+00B1, U+00B6, U+00BB, U+00BF, U+00D7 or U+00F7, U+2016–U+2017 or U+2020–U+2027, U+2030–U+203E, U+2041–U+2053, U+2055–U+205E)
(U+E0100–U+E01EF)Return to list