Theoretically Stuck

Ulf Wiger (TN/EAB) <>
Sat Sep 2 23:05:55 CEST 2006


When searching for some references, I came across
this:

http://www.erlang.org/ml-archive/erlang-questions/200603/msg00479.html
(Richard O'Keefe's draft proposal on child modules.)

But this was the one I was really after - ROK's 
dictionaries:

http://www.erlang.org/ml-archive/erlang-questions/200309/msg00339.html

BR,
Ulf W

> -----Original Message-----
> From: Rudolph van Graan [mailto:] 
> Sent: den 2 september 2006 22:30
> To: Ulf Wiger (TN/EAB)
> Cc: Erlang List
> Subject: Re: Theoretically Stuck
> 
> >>
> >> How do you write code that wraps the concept/data of a person? A 
> >> record with name and surname fields is the obvious answer:
> >>
> >> -record(person,{name,surname}).
> >>
> >>  From now on until forever, a person is a 3-tuple.
> >>
> >> Now I want to make a version of person with an extra field, say 
> >> telephone number. Not all records have this. Some have a 
> work address 
> >> as well.
> >
> > This seems to be leading towards wanting structs, right?
> > A dynamically typed associative array.
> 
> I'd be careful before I say yes because I have no clue what a DTAA is.
> 
> In my mind a list can almost do what I want:
> 
>    Type                 Name   Surname
> {[person],           ["Smith","Victor]}
> {[person,with_phone],["Smith", "Victor","+332211123123"]}
> 
> Both would match this pattern
> 
> {[person|_],[Name,Surname|_]}
> 
> and only the second one would match
> 
> {[person,with_phone|_],[Name,Surname|_]}
> 
> so we have a person-with-a-phone "inheriting" from person
> 
> Maybe wrap it in a tuple so that we know this is a 
> special,"inherited" type:
> 
> {dynamic_record,{[person,with_phone|_],[Name,Surname|_]}}
> 
> My biggest concern here is that you lose the implicit 
> efficiency of tuples, but I haven't measured how slow it is 
> yet and we've lost record syntax. 
> 



More information about the erlang-questions mailing list