[erlang-questions] Define "exists".

Vlad Dumitrescu vladdu55@REDACTED
Thu Oct 13 15:28:55 CEST 2011


Hi,

I think that the modules defining the atoms must be loaded when you call
to_existing_atom.

Can you preloaded those?

Regards, vlad
 On Oct 13, 2011 3:24 PM, "Eric Newhuis (personal)" <enewhuis@REDACTED>
wrote:

> 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:
>
> http://www.erlang.org/doc/man/erlang.html#list_to_existing_atom-1
>
> list_to_existing_atom(String) -> atom()
>
> Types:
>  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.
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111013/93f6dba2/attachment.htm>


More information about the erlang-questions mailing list