compiler optimisation of constant expressions

Andreas Schultz <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <CAC=ZbaR8WY9CxwVRaYMCExE6bLiuBQJ9k1Eeqg_povLjEZqmmw@mail.gmail.com>
Hi,

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-23.3.4.5 it turned out that the compiled beam
file still contained the atom_to_list and integer_to_list calls, e.g. this
code snippet:

test() ->
    ?FUNCTION_STRING.


Is contained in the beam file as:

test() ->
    "test_mod" ++ ":" ++ atom_to_list(test) ++ "/" ++ integer_to_list(0).


What I would have expected is this:

test() ->
    "test_mod:test/0".


Has the optimization been lost or was it never implemented or am I doing
something wrong?

Regards,
Andreas
-- 

Andreas Schultz
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.