-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Named precedence levels #180
Comments
Why don't just use an operator as a precedence level? Something like |
That could work, and it’s been done in a few languages, at least Perl6 and Fortress. I just figured it would come out more organised to use names for the groups, provided we can come up with sensible names. |
To be honest, the concept of precedence levels by itself feels like a kludge. Even though it is a most simple and direct way to implement precedences. |
Interesting alternative approach: https://youtu.be/EZD3Scuv02g?t=31m42s |
Its may be worth to do operator precedence like in Agda: you can only declare fixity and the fact that the operator in question binds tighter that some other (and the relation is not transitive). Using operators with no order known without putting one of subexpr in Then you have to construct a lattice, of course. |
There aren’t many operators defined in the common vocabulary yet, so we still have the chance to figure out the ergonomics of custom operators. Instead of the current 0–9 precedence levels, it might be better to use named precedence levels, under the assumption that most operators could (and should) fall into a clear family, such as:
tight exponential
^
*tight multiplicative
*
/
%
tight additive
+
-
~
**relational
<
>
<=
>=
=
<>
loose multiplicative
&
&&
loose additive
|
||
-->
--->
* not yet in the common vocab
** strict difference (xor)
Pros and cons:
With names, it’s easier to decide which precedence level to use for an operator
With names, we can easily add additional precedence levels later on between existing levels
With numbers, it’s easier to know which operator binds tighter
The text was updated successfully, but these errors were encountered: