[erlang-questions] Define "exists".
Thu Oct 13 21:48:43 CEST 2011
Why do they need to be atoms?
We have a very similar case, where we take HTTP headers from calls to our
own servers and turn them into proplists, with atoms for the header kinds
("content-type," "cache-control" etc).
However, we'd probably be just as well off, if not better, to use binaries
as the keys -- we get those straight out of the HTTP request anyway. Then we
don't have the problem of growing atom store, and/or having to pre-declare
all possible headers we might care about.
Americans might object: there is no way we would sacrifice our living
standards for the benefit of people in the rest of the world. Nevertheless,
whether we get there willingly or not, we shall soon have lower consumption
rates, because our present rates are unsustainable.
On Thu, Oct 13, 2011 at 6:24 AM, Eric Newhuis (personal) <enewhuis@REDACTED
> The problem is with list_to_existing_atom/1. Really it is a great idea.
> 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
> 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.
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions