This is the mail archive of the
kawa@sourceware.cygnus.com
mailing list for the Kawa project.
Re: Association lists
- To: kawa <kawa at sourceware dot cygnus dot com>
- Subject: Re: Association lists
- From: Marco Vezzoli <marco dot vezzoli at st dot com>
- Date: Fri, 23 Jun 2000 07:37:19 +0200
- Organization: sgs-thomson
- References: <s9526b8b.033@tapsellferrier.co.uk>
nferrier@tapsellferrier.co.uk wrote:
>
> >>> "Brian D. Carlstrom" <bdc@zurich.ai.mit.edu> 22-Jun-00 7:13:12 PM
> >>>
>
> >Associative arrays are not hashtables, although they
> >have a similar API, because their performance is not
> >equivilent
>
> I appreciate that.
>
> But it's as near as dammit because an assoc-list is only an
> assoc-list whilst it has associaton pairs on it. It wouldn't be a
> problem (from the user's point of view) to optimize it into a
> hashtable within the compiler or interpreter.
>
> This, it seems to me, would be the Scheme way - expressive and
> minimalist but with hidden, implementation driven, power (a la
> loops).
>
The scheme solution IMHO is
hash table=vector of alists + hash function.
It has the same (theorical) performance of a java hash table and is
portable; slib has some implementations; however you have to manage the
gory details of rehashing in order to keep the load factor optimal.
Association lists are a good solution for almost-constant small
dictionaries and take advantage of the easy definition of literals in
scheme; when I need the full power of an hash table with kawa I use the
native java hashes (portability is not one of my concerns) and a small
api to convert alists into hash tables and vice versa.
I'm not sure that the behaviour of an 'intelligent list' is really easy
to define.
Marco
--
(--cafe babe--)
Marco Vezzoli marco.vezzoli@st.com
CR&D Intranet Developement STMicroelectronics
tel. +39 039 603 6852 fax. +39 039 603 5055