> On Oct 20, 2016, at 12:25 PM, Jonathan Hull via swift-evolution
> <[email protected]> wrote:
>
> These can be used as identifiers unless they have been defined as an operator
> somewhere within the project, at which point they switch to being only usable
> as operators.
Imagine you're the compiler and you've been handed this source file:
let party = ππ
prefix operator π
You're going to see a keyword "let", an identifier "party", an "=" operator,
and then the sequence "ππ". How will you interpret that sequence? There are a
few possibilities:
1. A two-character variable named "ππ".
2. A prefix "π" operator followed by a one-character variable name "π".
3. A two-character operator "ππ" with an operand to follow on the next line.
4. A one-character variable name "π" followed by a postfix "π" operator.
The operator declaration on the next line will make all of this clearβbut we
can't understand the next line until we've parsed this line (see #3).
Now, one way around this would be to require all operator declarations to be at
the top of the source file. But this would be very strange in Swift, which is
otherwise completely insensitive to the order of statements in a declaration
scope. And it leads to a strange two-phase behavior when parsing multiple
files: You would need to parse each file through the end of its operator
declarations before parsing any other code in any of the other files.
I don't think this is something we want to do.
--
Brent Royal-Gordon
Architechies
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution