Is it a list ? & atoms defined

Inswitch Solutions - Erlang Evaluation erlang@REDACTED
Thu Jul 10 18:48:47 CEST 2003


The same happens with
list_to_atom([1-2]).

is_list[1-2] = true

Please, does someone know how to list the atoms already defined in the
runtime ?
The file created when ERTS crash (crash-dump) dumps all the atoms defined.


/Eduardo


----- Original Message -----
From: "Richard Carlsson" <richardc@REDACTED>
To: "Marc Ernst Eddy van Woerkom" <Marc.Vanwoerkom@REDACTED>
Cc: <erlang-questions@REDACTED>
Sent: Thursday, July 10, 2003 11:12 PM
Subject: Re: Is it a list ?


> ----- Original Message -----
> From: "Marc Ernst Eddy van Woerkom" <Marc.Vanwoerkom@REDACTED>
> To: <luke@REDACTED>
>
>
> > >   > But why is is_list([1|2]) true?
> > >
> > >   Probably because a proper test would mean traversing all the way to
> > >   the end, which could be expensive.
> >
> > I would prevent that by trying to make it impossible to
> > create inproper lists in the first place.
> > The question is, if this would be possible.
>
> Possible, yes (although it would break some existing code, of course)
> but it would also be expensive. For each new cons cell created,
> you would get a test-and-branch. It is simply much more convenient
> to allow any term in the second argument, and let the users decide
> how to use the cons cells - for proper lists only, or for tree-like
> structures as well. In Erlang programs, you don't see non-proper
> lists being used often.
>
> Of course the 'is_list' test could have been given the more correct name
> 'is_nil_or_cons_cell', but when you've typed that enough times, you tend
> to say "screw correctness, I want a shorter name for this thing!". And
> generally you do not want to traverse the whole list for each test, so
> making 'is_list' only yield true for proper lists is not a good solution
> either.
>
>     /Richard
>




More information about the erlang-questions mailing list