This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Scheme style auto-resizing hashtable (fwd)



jglascoe@jay.giss.nasa.gov writes:
> On Sun, 15 Nov 1998, Jay Glascoe wrote:
> 
> > The source code, a makefile, and test scripts are available at
> > 
> > http://www.giss.nasa.gov/~jglascoe/GUILE/hash-table.tar.gz
> 
> 
> The hash-table API consists of 18 useful procedures,
> not counting the 'v'/'q'/'x' variations.
> 
> 	*** predicate: ***
> 
> hash-table? object
>     your basic predicate.  Caution: this is not 100% fool-proof.
> 
> 	*** constructors: ***
> 
> make-hash-table
> make-hash-tablev
> make-hash-tableq
> make-hash-tablex user-equal? user-hasher
> 
> 	*** translators: ***
> 
> list->hash-table list [wrapper]
> list->hash-tablev list [wrapper]
> list->hash-tableq list [wrapper]
> list->hash-tablex list user-equal? user-hasher [wrapper]

Can you change these to alist->hash-table*, since they conver
association lists?

> list->hash-table! list [wrapper]
> list->hash-tablev! list [wrapper]
> list->hash-tableq! list [wrapper]
> list->hash-tablex! list user-equal? user-hasher [wrapper]
>     Similar to the non-destructive procedures above.
>     Magically turn list "list" into a hash-table.  Return value
>     is unspecified.  Note: "list" must be nonempty.
> 

Destructive conversion functions are a bad idea and cannot
generalize. Taking advantage of the fact that a hash table is
fundamentally a cons cell will make things lose big if you ever change
your underlying implementation, for instance.

 
> hash-table-consume-list! hash-table list [wrapper]
>     Similar to the non-destructive "hash-table-add-list!" above.
>     Delete list "list" while inserting (wrapper list-element)
>     into hash-table "hash-table" for all of "list"'s elements.
>     Return value is unspecified.
> 

I still argue this is useless, especially since Guile is getting a
generational GC.  Bloating the API unnecessarily is a bad thing.

 - Maciej