diff options
author | Björn Gustavsson <[email protected]> | 2017-09-14 07:05:29 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2017-09-14 10:01:12 +0200 |
commit | 0f5c4c923208b63ab645341883637318775d81d1 (patch) | |
tree | f5dc753ac4466b223abab4e9084648c23a5b0cee /erts/doc/src/notes.xml | |
parent | 8e5fff1eb3a967ebc66c4cec1dd91699cdea66c0 (diff) | |
download | otp-0f5c4c923208b63ab645341883637318775d81d1.tar.gz otp-0f5c4c923208b63ab645341883637318775d81d1.tar.bz2 otp-0f5c4c923208b63ab645341883637318775d81d1.zip |
Document that the compiler may optimize away atoms
The following code could fail in the call to list_existing_atom/1:
String = atom_to_list(some_atom),
Atom = list_to_existing_atom(String)
because the compiler will rewrite the code to:
String = "some_atom",
Atom = list_to_existing_atom(String)
If some_atom is not used in another place, it will not exist.
The compiler could be updated to preserve the atom in this simple case,
but it would be hard to make sure that the compiler never loses atoms
that exist in the source text. It also difficult to imagine a
real world use case where this would be a problem. If an atom is
mentioned only in a way that the compiler can optimize away, is there
really any need to create the atom at all in list_to_existing_atom/1?
Therefore, it is better to place the responsibility that the atom exists
on the user of list_to_existing_atom/1. Update the documentation to
mention that the compiler may optimize away atoms.
https://bugs.erlang.org/browse/ERL-453
Diffstat (limited to 'erts/doc/src/notes.xml')
0 files changed, 0 insertions, 0 deletions