[erlang-questions] Why should you ever use atoms?
Pierre Fenoll
pierrefenoll@REDACTED
Sat Oct 10 17:59:54 CEST 2015
Atom comparison is O(1) (and just one word).
String comparison is O(n)
> On 10 Oct 2015, at 08:46, Thomas Gebert <thomas@REDACTED> wrote:
>
> I know this is probably kind of a newbie question, but I figured this would be the place to ask it: if atoms aren't garbage collected, why should I use them? For example, it's a common pattern to have something like:
>
> myFunction({user, "tombert","eats pizza"}) -> %% do something
>
> When I could easily do something like:
>
> myFunction({"user", "tombert", "eats pizza"}) -> %% do something
>
> ----
>
> I could be way off here, but wouldn't the string be garbage collected? Is there a benefit to atoms that I'm missing?
>
> -Tombert.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
More information about the erlang-questions
mailing list