[Prev][Next][Index][Thread]

subscripts on operators (etc)



Bruce claimed that it was not possible in an operator precedence parser
to (cleanly) have subscripted operators, or more generally, embellished
operators.  This is not true, and I can offer the typesetting system
in Mathematica as a counter-example.  I talked to Bruce over the phone to
explain how this is done (it requires extra work), and he agrees that it is
possible.  The one piece of information that you need is whether an operator
is a 2-d structure creating operator or not.

For example, in Mathematica's typesetting syntax,

a +  b
   n

is represented as "a + \_ n b", where \_ is the subscript operator.
2-d structure creating operators do their 'error correction' operations
differently than regular "linear" syntax.

Mathematica's typesetting syntax has the following 2-d operators:
a \/ b         fraction
a \^ b         superscript
a \_ b         subscript
a \_ b \% c    sup and superscript
a \+ b         underscript (lower limit)
a \& b         overscript (upper limit)
a \+ b \% c    underscript (lower and upper limit)
\@ a           square root
\@ a \% b      'b'th root of 'a'

The 2-d operators are escaped so that the characters '/', '^', etc.,
all simply represent themselves.

"a \_ b \% c" is used instead of "a \_ b \^ c" because the later would
mean (a \_ b) \^ c (the superscript would be to the right of the subscript
instead of over it).

An embellished operator has the same precedence as an unembellished operator
(as Ron Whitney pointed out in his mail).

Since human readability and writeable seems to be of high importance to this 
group, and since '^' and '_' will be much less frequently used in HTML than
in Mathematica, I think switching the '^' and '\^' (etc) makes sense for HTML
math.  Ie, let '^' be the superscript operator and let '\^' stand for the
character '^'.  Given this, expressions such as

y = ∫ _ 0 % 1 sin^2(x) ⅆ x

are parseable. To me, this notation is fairly clean and has, I think all of
the properties that we are looking for in HTML math's notation.  Opinions?

	Neil


Follow-Ups: