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

Re: notation for extending precedence



Maybe I can explain my question even better, now:
what I am asking about is not how to do anything
algorithmically, but what single notation for new operators
can conveniently handle all three common cases of how
one would like to define them:

- just lower (or higher) in precedence than the previous operator
in the list (without naming it);

- the same precedence as the previous operator in the list
(without naming it);

- just lower, higher, or the same, in precedence as some
named operator.

Now that I explain the question this way, one possible answer is
apparent -- just use your suggested notation, but with
an additional keyword :previous to use in place of the operator
name. So you could make incremental definitions relative to
the precedence of named operators, but let the definitions in
your large file of built-in operators be relative to whatever
operator came just earlier in the list, regardless of name.

This is still not good enough with regard to editing the main
list to change the order within a group of operators of the
same precedence, since the first one of the group is the one
which has to say it is :lower-than :previous rather than
:same-as :previous.

This problem is analogous to the problem
with comma-separated list formats, when you want to add or delete
items at the end, or reorder items including the one at the end.
This is (I imagine) why the C programing language allows a trailing
comma at the end of an array initializer.

- Bruce