Specify symbolic operator prescedence

This has probably been talked about before, but are people open to introducing a system for specifying symbolic operator prescedence? I’m thinking particularly of non-ascii, unicode operators. E.g. allowing us to specify that in A⨯B⟶C⨯D that ⨯ binds more tightly than ⟶. I realise that re-binding the prescedence of standard ascii operators is likely to cause problems, and indeed, potentially the left-to-right vs right-to-left associativity. But the mathematical symbols are a beautiful playground.

This would apply both to type constructors and to functions, I think.

1 Like

Many languages map operators onto integers and then do ordering that way. An alternate strategy might be to use scala’s approach or lexicographic sorting, but allow a def to declare a list of operators it binds binds above or below, anything not in that list falls back to lexicographic.

Something like:

class Foo {
  def *(that: Foo) = ...

  def +(that: Foo) = ...

it would be an error if those declaration don’t form a lattice (i.e. there is a cycle).

oh… please don’t do that.

From the olden days… This was my attempt to synthesize a stable point in the debate. I’m not sure much has changed since then, although Dotty’s increased modularity might make things more tractable?

What I saw as the crux of the issue, with some paraphrasing to clarify:

the parser understands [the built-in precedence rules], information about [user-defined precedence info] would only become available after the typer has run, and the information flow from parser to typer is one-way.