Construct for associative arrays

Robert Virding <>
Tue Feb 9 12:51:36 CET 1999


 writes:
>Hi,
>
>Suppose I have a record:
>
>  -record(aap,{ johnnie }).
>
>a function:
>
>  name() -> johnnie.
>
>and a variable assignment:
>
>  Var = #aap{ johnnie=mad },
>
>Now my question is: would it be TERRIBLE difficult to implement Erlang such
>that I could address a record member as follows:
>
>  Var#aap.name()
>
>This way, working with associative arrays would become very simple. And these
>data structures are quite useful, once you are accustomed to them.

Basically what you are after is to be able to determine the field name
of a record at runtime.  This was discussed when records were added
but we decided not to do it.  It can be added if the desire is
overwhelming. :-)

The syntax would be with current priorities:

	Var#aap.(name())

Definitely look ROK's abstract patterns which Torbjörn mentioned, they
are also implementable on demand.

	Robert



More information about the erlang-questions mailing list