[swift-evolution] Allowing Characters for use as Custom Operators
me at jo2.co
Fri Jan 8 02:29:32 CST 2016
> The rationale is the same - the design of Swift really wants operators and identifiers to be partitioned into different namespaces. Violating that would make it impossible to parse a swift file without parsing all of its imports. This is a mistake that C made (you have to parse all the headers a file uses to reliably parse the file) that we don’t want to replicate in Swift.
Thanks Chris. I now understand the reasoning for separating the two groups. I don’t have a background in language creation, so whatever I can learn from these email lists is awesome. I have already gained a ton of knowledge following these conversations.
> Alternative: Reserve one of the operator characters as an operator introducer. Everything from that character to the next whitespace is an operator name. This would allow non-operator characters in operator names while still preserving the strict operator/identifier separation.
> // • is the operator introducer character
> infix operator •times …
> infix operator •mod …
> x = a •times b •mod 8
> You still can't use an unadorned word as an operator name.
> You can't use such an operator without whitespace (unlike operators whose names use operator characters only).
Oooooo … that is a very cool alternative Greg. Honestly went into this proposal thinking there was no possibility, but now I have a glimmer of hope.
Using “•” (option + 8 on keyboard) would be great since it is accessible through key combo, but isn’t widely used in normal expressions.
What is needed to prove worth of such a feature to be added?
Nerd . Designer . Developer
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution