reason icon indicating copy to clipboard operation
reason copied to clipboard

`++` operator is right associativity

Open bobzhang opened this issue 4 years ago • 5 comments

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

bobzhang avatar May 16 '20 08:05 bobzhang

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

TheSpyder avatar May 18 '20 23:05 TheSpyder

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

bobzhang avatar May 19 '20 00:05 bobzhang

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

TheSpyder avatar May 19 '20 00:05 TheSpyder

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 avatar May 28 '20 06:05 jordwalke

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").

jordwalke avatar May 28 '20 06:05 jordwalke