superscripts, subscripts, etc.

Chris Lattner wrote:

Just FWIW, IMO, these make sense as operators specifically because they are commonly used by math people as operations that transform the thing they are attached to. Superscript 2 is a function that squares its operand. That said, perhaps there are other uses that I’m not aware of which get in the way of the utilitarian interpretation.

But there are SO MANY uses for superscripts, subscripts, and other such annotations, and they are all context specific, just in math, without getting into chemistry, physics, statistics, and so forth.

They’re really more like methods on the object to which they’re attached, or the combination of a method and an argument. Wouldn’t classing them as identifiers lend itself better to this?

Apologies in advance if this is a waste of everyone’s time.

- John Payne

Chris Lattner wrote:

Just FWIW, IMO, these make sense as operators specifically because they are commonly used by math people as operations that transform the thing they are attached to. Superscript 2 is a function that squares its operand. That said, perhaps there are other uses that I’m not aware of which get in the way of the utilitarian interpretation.

But there are SO MANY uses for superscripts, subscripts, and other such annotations, and they are all context specific, just in math, without getting into chemistry, physics, statistics, and so forth.

They’re really more like methods on the object to which they’re attached, or the combination of a method and an argument.

I agree.

Wouldn’t classing them as identifiers lend itself better to this?

No, making them an operator is better for this usecase.

You want:

x² to parse as “superscript2(x)” - not as an identifier “xsuperscript2” which is distinct from x.

-Chris

···

On Oct 2, 2017, at 10:56 PM, John Payne via swift-evolution <swift-evolution@swift.org> wrote:

I am of two minds on this. Sometimes I want x² to parse as x*x (an
operator) but other times I want to store the value of x*x in an identifier
spelled… x². This could be simply to avoid repeatedly performing the same
calculation, or it could be the natural result as in,

let r² = someStatisticsThing(xVals, yVals)

Not sure where I’m going with this, just wanted to mention it.

Nevin

···

On Tue, Oct 3, 2017 at 2:02 AM, Chris Lattner via swift-evolution < swift-evolution@swift.org> wrote:

You want:

x² to parse as “superscript2(x)” - not as an identifier “xsuperscript2”
which is distinct from x.

-Chris