[swift-evolution] [Proposal] Refining Identifier and Operator Symbology
Jonathan S. Shapiro
jonathan.s.shapiro at gmail.com
Thu Oct 20 10:21:00 CDT 2016
On Thu, Oct 20, 2016 at 8:08 AM, Erica Sadun <erica at ericasadun.com> wrote:
> I really liked Jonathan's suggestion that removed the distinction between
> operators and identifiers entirely. You could mark a one-argument function
> as postfix or prefix, and a two-argument function as infix and use them as
> a kind of pseudo keyword.
>
Please excuse me if I booger the syntax here, but here is what this would
look like:
// Bind + as a function name in the usual way:
func +(a, b) -> { ... }
// Say we are treating + as a quasi-keyword with the given precedence.
// Requires that + be bound (before or after) as a two argument function
if infix, or a one argument function if prefix/postfix:
infix operator + : TheUsualPrecedevnce
// Parenthesizing a quasi-keyword lets you use it as an identifier:
+ // is an operator
(+) // is a use-occurrence of the function named +
I understand why collapsing the two may seem appealing, but my personal
opinion is keep separate things separate.
Even if the eventual consensus is to collapse them, let's first discuss
them as separate things so we can understand the two things that are being
said.
Jonathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161020/27077e1b/attachment.html>
More information about the swift-evolution
mailing list