diff options
author | Björn Gustavsson <[email protected]> | 2017-09-15 10:06:46 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2017-09-15 10:06:46 +0200 |
commit | fd831cb49994fac7db32a058afeb3a766c8112b1 (patch) | |
tree | 2a2bc6d10aaeeb8728115ab265c38a535b2785e4 /erts/doc | |
parent | dbe18b8380b0619c60cd57c803a9204c04eceadb (diff) | |
parent | 0f5c4c923208b63ab645341883637318775d81d1 (diff) | |
download | otp-fd831cb49994fac7db32a058afeb3a766c8112b1.tar.gz otp-fd831cb49994fac7db32a058afeb3a766c8112b1.tar.bz2 otp-fd831cb49994fac7db32a058afeb3a766c8112b1.zip |
Merge pull request #1566 from bjorng/bjorn/erts/fix-existing-atom-doc/ERL-453
Document that the compiler may optimize away atoms
OTP-14614
Diffstat (limited to 'erts/doc')
-rw-r--r-- | erts/doc/src/erlang.xml | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/erts/doc/src/erlang.xml b/erts/doc/src/erlang.xml index 5afac46d21..2465f49581 100644 --- a/erts/doc/src/erlang.xml +++ b/erts/doc/src/erlang.xml @@ -432,6 +432,16 @@ Z = erlang:adler32_combine(X,Y,iolist_size(Data2)).</code> <seealso marker="#binary_to_atom/2"><c>binary_to_atom/2</c></seealso>, but the atom must exist.</p> <p>Failure: <c>badarg</c> if the atom does not exist.</p> + <note> + <p>Note that the compiler may optimize away atoms. For + example, the compiler will rewrite + <c>atom_to_list(some_atom)</c> to <c>"some_atom"</c>. If + that expression is the only mention of the atom + <c>some_atom</c> in the containing module, the atom will not + be created when the module is loaded, and a subsequent call + to <c>binary_to_existing_atom(<<"some_atom">>, utf8)</c> + will fail.</p> + </note> </desc> </func> @@ -2478,6 +2488,15 @@ os_prompt%</pre> but only if there already exists such atom.</p> <p>Failure: <c>badarg</c> if there does not already exist an atom whose text representation is <c><anno>String</anno></c>.</p> + <note> + <p>Note that the compiler may optimize away atoms. For + example, the compiler will rewrite + <c>atom_to_list(some_atom)</c> to <c>"some_atom"</c>. If + that expression is the only mention of the atom + <c>some_atom</c> in the containing module, the atom will not + be created when the module is loaded, and a subsequent call + to <c>list_to_existing_atom("some_atom")</c> will fail.</p> + </note> </desc> </func> |