list_to_atom use in kernel/error_logger.erl

Serge Aleynikov <>
Thu Feb 2 00:34:20 CET 2006


Matthias,

Thank you for clarification.  The reason I looked into the 
error_logger's code was indeed related to the ugly format of the 
displayed message upon an unsuccessful startup with a -boot option.

Though I still don't understand the need for list_to_atom(L) there.  Why 
not just return the list L?  It does work either way.

Serge

Matthias Lang wrote:
> Hi,
> 
> Short answer: It's not a problem, the offending code is only 
>               executed during the Erlang boot.
> 
> Long answer: This seemed like a jolly good opportunity to make the
> emulator crash and burn. Alas, it's harder than hoped. 
> 
> The manpage for the error_logger hints (see swap_handler) that the
> error_handler starts up in a 'primitive' state, before being moved to
> 'normal' mode. The code you posted is only reachable from that
> primitive state, so there's not much scope for logging a bunch of junk
> with it. 
> 
> If you insist on clogging the works, you can use the undocumented export
> error_loger:simple_logger/1 with an integer argument.
> 
> Matthias
> 
> --------------------
> 
> Serge Aleynikov writes:
>  > I was browsing through the kernel/error_logger.erl and the following 
>  > code caught my attention.  Wouldn't the call list_to_atom/1 eventially 
>  > lead to exhaustion of the atom table?
>  > 
>  > ----kernel/error_logger.erl (line: 288)-------------------
>  > display2(Tag,F,A) ->
>  >      erlang:display({error_logger,Tag, nice(F), nice(A)}).
>  > 
>  > nice(X) when tuple(X) ->
>  >      nice_tuple(X);
>  > 
>  > nice([]) -> [];
>  > nice(L) when list(L) ->
>  >      case is_string(L) of
>  >      true ->
>  >          list_to_atom(L);
>  >      false ->
>  >          [H|T] = L,
>  >          [nice(H) | nice(T)]
>  >      end;
>  > nice(X) -> X.
>  > ----------------------------------------------------------
>  > 
>  > Why does a list need to be converted to atom here?
>  > 
>  > Serge
> 

-- 
Serge Aleynikov
R&D Telecom, IDT Corp.
Tel: (973) 438-3436
Fax: (973) 438-1464




More information about the erlang-questions mailing list