Nothingness

Erik Pearson <>
Sat Oct 27 17:43:26 CEST 2001


Aye, the rub: this is a mnesia table on disk, where atoms are stored as 
binaries.

--On Saturday, October 27, 2001 4:56 PM +0200 Robert Virding 
<> wrote:

> 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.

That might have been helpful --

Is there a technical reason why there could not be a special type of term 
-- not an atom, a list, or anything else -- which means 'undefined'?

It could be detectable with the function "is_undefined/1" or 
"is_defined/1", and set with "undefined/0"... perhaps would need its own 
printable representation... could have its own binary transformation...


Erik.

>
> Robert
>
> Erik Pearson <> 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.



Erik Pearson
@ Adaptations
email     : 
voice/fax : +1 510 527 5437
text page : 




More information about the erlang-questions mailing list