Nothingness

Robert Virding rv@REDACTED
Sat Oct 27 16:56:48 CEST 2001


Why all this?

As you state at the end 'undefined' is just an atom.  This means that
its storage IS efficient in a mnesia table, at least for tables in
memory, and the length of the atom is irrelevant.  All that is stored
is an atom identifier.

I suppose we could have called the atom '$undefined$' or some such to
make it a little more clear that this value was different.

Robert

Erik Pearson <erik@REDACTED> writes:
>Or this:
>
>-module(undef).
>-record(undef,{x}}.
>-export(undef/0).
>undef() -> (#undef{})#undef.x.
>
>Then if you do:
>
>c("undef").
>is_atom(undef:undef()).
>true
>
>And if you further explore, e.g.
>
>size(atom_to_binary(undef:undef())).
>13
>
>you'll find that all that is really returned is the atom 'undefined'. Not 
>very exciting :(
>
>However, 'undefined' is used throughout the otp (over 2K occurrences in the 
>erl source for lib) -- if you grep through the sources it is used 
>everywhere. There is one entry in the spec for 'undefined', and it is 
>uneventful. Alas, 'undefined' is just a regular atom, and a long one at 
>that, so unsuitable for storage in a mnesia table.
>
>Erik.



More information about the erlang-questions mailing list