Modulus Operator
We're starting a new project that will use tons of animation and decided Rescript is a strong candidate - we love it's support for React. During our testing phase we discovered there seems to be no modulus operator, for exmaple:
let a = b mod c;
This is well implemented in Reason, https://reasonml.github.io/api/Pervasives.html#VAL(mod).
Are there any plans to add support for this in Rescript?
No plans, but there is a built-in function that you can use with the pipe-operator
let a = b->mod(c)
ReScript tries to keep the reserved keyword space as small as possible and decided to make almost everything a function instead of an infix operator.
There exists also a prototype for custom infix operators which would enable you to assign the modulo function to an arbitrary string, but there seems not to be too much interest by the community. https://github.com/rescript-lang/rescript-compiler/pull/6076
OTOH I guess a fixed % as in JS would not hurt
@fhammerschmidt Thanks, mod(a, b) works for what we need.
Since ReScript is promoting syntactic features that make it look more like JS, I think it's a good idea to have the %, <<, >>, >>>, **, etc. be the same.
@namenu I agree, although mod() works for me specifically - if ReScript is promoting syntatic features that resemble javascript then at minimal all basic arithmetic syntax should be honored - even more, almost all other languages support %, imo it's simple to get right. I'm not a huge fan of Typescript but atleast it allows all javascript abilities, devs use Rescript and Typescript because javascript is not good enough - so I'm not pushing to make Rescript exactly like javascript but ateast include the basic syntax that most strongly typed ML languages support.
On a good note, I like that Rescript is TRUE static typing and can really be a contender in the cross-platform space.
Can you guys please consider completing the arithmetic components of your compiler?