default values in records

Vance Shipley <>
Mon Sep 1 11:45:15 CEST 2003


Now we can set all values in a record at once:

   "There is a new feature introduced in Erlang 5.1/OTP R8B,
    with which you can set a value to all fields in a record,
    overriding the defaults in the record specification. The
    special field _, means "all fields not explicitly specified".

    > #person{name = "Jakob", _ = '_'}.
    {person, "Jakob", '_', '_'}


But you can't specify them that way:

-record(person, {"John","Jakob","Jingleheimer","Schmidt",_=silly}).

Too bad too because I've got some nested records where I need all 
the fields defaulted to zero.  Because they're nested it's cumbersome 
to have to do the _=Value at each level especially when you don't
need to go down to that level for any other fields.  I can of course
set them each to zero in the specification, it would just be so much
prettier with the above syntax.

	-Vance



More information about the erlang-questions mailing list