compiler optimisation of constant expressions
Thu Sep 16 11:15:15 CEST 2021
I've stumbled upon a statement in EPP-0045 that made me wonder:
There is no run-time penality for defining `FUNCTION_STRING`
yourself, as the compiler will turn either definition of
`FUNCTION_STRING` into a literal string during compilation.
Historical note: `MODULE_STRING` was added as an optimization in OTP
R7B, because at the time the compiler did not optimize constant
expressions as well as it does now.
When I tested that on OTP-22.214.171.124 it turned out that the compiled beam
file still contained the atom_to_list and integer_to_list calls, e.g. this
Is contained in the beam file as:
"test_mod" ++ ":" ++ atom_to_list(test) ++ "/" ++ integer_to_list(0).
What I would have expected is this:
Has the optimization been lost or was it never implemented or am I doing
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions