[MLton] Ad-hoc infix identifiers, Printf, and libraries

Vesa Karvonen vesa.karvonen@cs.helsinki.fi
Thu, 14 Jul 2005 19:58:55 +0300


Quoting Andreas Rossberg <rossberg@ps.uni-sb.de>:
[...]
> >   operator * precedes +
> 
> The problem with this is that it is impossible to express precedences in 
> a modular way - you cannot define them independent from other operators. 
> For example, if you want to provide several libraries that are 
> independent but whose infix operators should be combinable in a 
> convenient way, then you probably cannot.

I'm not exactly sure what you have in mind.

One could, for example, introduce virtual or place-holder operators for
making it easier to combine groups of precedences.  Basically, a library
would introduce fixity declarations that are only used for the purpose of
allowing users to declare precedences relative to the actual operators
in the library robustly and conveniently.  For example, suppose that you
would have the declarations

  operator maxBinPrec precedes & precedes ^ precedes | precedes minBinPrec

and

  operator maxArithPrec precedes *, / precedes +, - precedes minArithPrec

in different libraries.

You could then combine them by declaring

  operator minArithPrec precedes maxBinPrec

Now all the Arith-operators would precede all the Bin-operators (by
transitive closure).

But this is probably getting off-topic...

-Vesa Karvonen