According to this comment Belt.Array, Js.Array, Js.Array2 - #5 by chenglou (which is really concerning to read as a newcomer…); Js.Array2 shouldn’t be used in the first place? I see there is also Belt.Array, is it actually recommended to blindly use this one instead of Js.Array2 if we don’t care about the runtime overhead? If yes, it looks like there is no equivalent in Belt.Array to Js.Array2.pushMany, is there something else I should be using that I missed?
Custom operators are used a lot in languages like OCaml, depending on the team. Overdoing them can lead to unreadable code though, so it’s probably a good idea to only introduce them for frequently used operations, so that:
The existence of the operator is well justified.
All the team has a great chance to learn it and not be puzzled by it.
In ReScript specifically, custom operators are encouraged less than in some other languages, because the core team doesn’t really endorse them, and because a better support of them by the parser would require some work by that same team. But they’re here for legacy reasons, and some devs coming from OCaml/ReasonML swear by them.
It looks a bit magical to me.
It’s not really magical in the sense that something is happening that is not obvious from your immediate code (as far as you know what the operator does). In a lot of functional languages, an expression with an infix operator is just a syntax sugar for a binary function call, so 1 + 2 is just sugar for (+)(1, 2).