[MLton] property-list vs. hashtable
Matthew Fluet
fluet@cs.cornell.edu
Thu, 2 Dec 2004 13:36:09 -0500 (EST)
> It would be nice to do an experiment to use hash tables instead of
> property lists. Unfortunately, I don't see how to do it without
> rewriting all the uses of property lists. I don't think your proposal
> works.
>
> > functor PropertyList(H: HASH_TABLE): PROPERTY_LIST =
> > struct
> > datatype t = T of Word.word * unit ref
> >
> > local
> > fun pseudo-rand () = ...
> > in
> > fun new () = T (pseudo-rand(), ref ())
> > end
> >
> > fun newProperty () =
> > let
> > val ht = HashTable.new {hash = fn T (w, _) => w}
> > ...
> > end
> > end
>
> For the hash table to work, you need to hash each element of X,
> i.e. each variable. What you've written here only has a hash for each
> property. I don't see how it can be made to work with the current
> interface. We need something more like
I don't understand your objection. The hash for each element of X is it
Word.word in the "property-list" associated with X. Every property get's
its own hash-table, but they all share the same hashing function.