[erlang-questions] Define "exists".

Eric Newhuis (personal) enewhuis@REDACTED
Thu Oct 13 15:24:12 CEST 2011

The problem is with list_to_existing_atom/1.  Really it is a great idea.  But...

1.  I have raw query strings coming in from the cruel outside world.
2.  I convert some bits of those into atoms by way of list_to_existing_atom so that someone cannot kill me with DOS attack by bloating my atom table.
3.  With me so far?  Good.
4.  My server, an OTP app, has a .app file that lists several other apps.
5.  list_to_existing_atom fails on atoms defined in those several other apps.

Suggestion:  The documentation should specify what "exists" really means.

Question:  What should I do to force the atoms from my dependent apps to be loaded?  I've been manually calling Module:module_info/0 just in time but, alas, this is starting to fail due to other module dependencies that are unknown at my call sites.

For reference, here is the existing Erlang doc from the .org site:

list_to_existing_atom(String) -> atom()


String = string()

Returns the atom whose text representation is String, but only if there already exists such atom.

Failure: badarg if there does not already exist an atom whose text representation is String.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111013/4a6aafe0/attachment.htm>

More information about the erlang-questions mailing list