Did rescript removed preval of const expressions?

Right now I see the following behavior for static constant expressions which I am pretty sure didn’t work this way in bucklescript + reasonml

Like here rescript omits unoptimized calculation

Or even does not prevaluate constants.
var audio_height = 120.0 / 2.0;

This kind of optimisation is kind of killer feature of compiled-to-js languge IMHO. Or maybe I am doing something wrong? Is there any way to turn on the optimiser like flambda?

1 Like

Hi, we did not do such things for floating point number as it will get tricky. e.g, 1.0 / 3.0

5 Likes

It seems like integer division never was pre-evaluated either.

Reason
Rescript

Huh, never knew about it works that way until today.
I was searching through the docs but did not manage to find a page where pre-evaluation is documented. Am I using the wrong keywords or such a page does not exist?

1 Like

:open_mouth: I was really surprised that this really works only with integers Reason · Reason lets you write simple, fast and quality type safe code while leveraging both the JavaScript & OCaml ecosystems.

Thanks for answering, probably the great thing to add to the docs as a feature of Rescript

1 Like