Erlang/OTP Forums

Author Message

<  Erlang questions mailing list  ~  Construct for associative arrays

wboeke at hzsbg01.nl.luce
Posted: Mon Feb 08, 1999 4:32 pm Reply with quote
Guest
--------------------------------------------------------------------
From: W.Boeke, Lucent Technologies, boeke_at_lucent.com
To : Erlang discussion group, erlang-questions_at_erlang.org
Date: febr 8, 1999
--------------------------------------------------------------------

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.


Kind regards,
Wouter Boeke


Post generated using Mail2Forum (http://m2f.sourceforge.net)
tobbe at serc.rmit.edu.au
Posted: Tue Feb 09, 1999 1:03 am Reply with quote
Guest
> Now my question is: would it be TERRIBLE difficult to implement Erlang such
> that I could address a record member as follows:

Richard O'Keefe has come up with a much better solution
called "Abstract Patterns", which he presented at the
last Erlang User's Conference. You'll find his slides
at (in powerpoint):

http://www.erlang.se/onlinenews/New/Slides/Abstract_Pattern_Matching_for_Erlang.ppt

Basically, Abstract Patterns removes the need for records
and the Erlang preprocessor.

> This way, working with associative arrays would become very simple. And these
> data structures are quite useful, once you are accustomed to them.

Have you had a look at:

http://www.erlang.org/user.html#assoc-1.2

/Tobbe



Post generated using Mail2Forum (http://m2f.sourceforge.net)
rv at erix.ericsson.se
Posted: Tue Feb 09, 1999 11:51 am Reply with quote
Guest
wboeke_at_hzsbg01.nl.lucent.com 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
tobbe at serc.rmit.edu.au
Posted: Tue Feb 09, 1999 12:03 pm Reply with quote
Guest
rv> Definitely look ROK's abstract patterns which Torbj

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum