Nothingness

Erik Pearson <>
Sat Oct 27 05:03:21 CEST 2001


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.

--On Friday, October 26, 2001 8:52 PM -0400 Vance Shipley 
<> wrote:

>>
>> Interestingly, records do support the concept of "undefined" ...
>>
>> Erik.
>
> -module(undef).
> -export([test/0]).
>
> -record(r1, {name, phone, address}).
>
> test() ->
> 	#r1{name = "Joe", phone="5551234"}.
>
>
> Erlang (BEAM) emulator version 5.1 [threads:0]
>
> Eshell V5.1  (abort with ^G)
> 1> c(undef).
> {ok,undef}
> 2> undef:test().
> {r1,"Joe","5551234",undefined}
>
>
>
>
>    -Vance



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




More information about the erlang-questions mailing list