Skip to content

Change operator precedence to be left biased.#2685

Open
SanderSpies wants to merge 1 commit into
reasonml:masterfrom
SanderSpies:sanderspies/precedence
Open

Change operator precedence to be left biased.#2685
SanderSpies wants to merge 1 commit into
reasonml:masterfrom
SanderSpies:sanderspies/precedence

Conversation

@SanderSpies

@SanderSpies SanderSpies commented Feb 27, 2023

Copy link
Copy Markdown
Contributor

Make &, &&, |, ||, ++, and :: operators left associative.

The tradeoff here is between JS and OCaml.

Here’s the precedence list of JS: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#table

and here of OCaml:
https://v2.ocaml.org/api/Ocaml_operators.html

The important difference here is:

&, &&, |, ||, ^, :: right associative in OCaml (and current ReasonML default)
&, &&, |, ||, + left associative in JS. :: is obviously not present in JS and I decided to make that left associative as well as it “feels” more correct here.

See also: #2672

@SanderSpies SanderSpies changed the title wip: Change operator precedence to be left biased. Mar 6, 2023
@SanderSpies SanderSpies force-pushed the sanderspies/precedence branch from 336a70b to 559681e Compare March 6, 2023 08:40
@SanderSpies SanderSpies marked this pull request as ready for review March 6, 2023 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant