[erlang-questions] Introspecting the atom table

Kostis Sagonas kostis@REDACTED
Wed Dec 20 23:07:48 CET 2006


Eric Merritt wrote:
> Guys,
> 
>  Is there anyway to introspect the atom table? I would like to be able
> to take a string and check if that string has been interned in the
> atom table. Even better would be a bif that converts the string to an
> atom if that atom already exists and doesn't otherwise. I suspect that
> this type of functionality doesn't exist, but I thought I would ask
> and make sure.

Handle with care:


Eshell V5.5.2.1  (abort with ^G)
1> list_to_existing_atom("erlang").
erlang
2> list_to_existing_atom("gazonk").

=ERROR REPORT==== 20-Dec-2006::23:06:58 ===
Error in process <0.29.0> with exit value: 
{badarg,[{erlang,list_to_existing_atom,["gazonk"]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}

** exited: {badarg,[{erlang,list_to_existing_atom,["gazonk"]},
                     {erl_eval,do_apply,5},
                     {shell,exprs,6},
                     {shell,eval_loop,3}]} **

Kostis



More information about the erlang-questions mailing list