reasonml / reason

Simple, fast & type safe code that leverages the JavaScript & OCaml ecosystems
http://reasonml.github.io
MIT License
10.15k stars 428 forks source link

`++` operator is right associativity #2577

Open bobzhang opened 4 years ago

bobzhang commented 4 years ago

Most languages have + as left associativity, this applies to OCaml as well.

TheSpyder commented 4 years ago

isn't this because OCaml ^ is right associative and that's what ++ translates to?

bobzhang commented 4 years ago

In my opinion this is a leaky abstraction, when I am using reason syntax why do I need remember that it maps to ^ in ocaml

TheSpyder commented 4 years ago

Sorry, I didn't mean to question why we would change it, just why it ended up this way.

jordwalke commented 4 years ago

Yes, this should be changed and it's one of the things I've been planning to do in the next breaking change. It has to be in a breaking change though and those have to be batched. Thanks for reminding me.

jordwalke commented 4 years ago

The original reason for it being left associative is not a good reason. It was so that when converting from OCaml code, you don't end up with some really funny looking output like "((hi" ++ "bye") ++ "there").