[m-dev.] For review: hash table implementation

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Feb 2 13:50:12 AEDT 2001


On 01-Feb-2001, Ralph Becket <rbeck at microsoft.com> wrote:
> what is lacking is something like
> 
> 	:- func generic_hash(T) = int.

That could be implemented using the RTTI support,
e.g. std_util__deconstruct, of course.  But I don't happen
to have an implementation of it lying around, I'm afraid ;-)

Note that for data structures which might be large,
it's generally better to use tries rather than hash
tables.  The Mercury runtime system has an implementation
of tries which is used as part of our implementation of tabling. 
Unfortunately however, there's no nice Mercury-level interface to it.
(There is only an impure untyped Mercury-level interface.)

> Aside: is there any real point in providing float_hash_pred and
> char_hash_pred?
> The former sounds absurd and the latter is probably better served with a
> list
> or array based approach.

`char_hash_pred' exists, it is just spelt `char__to_int' ;-)

Hashing on floats is almost always a bad idea.
So I don't think it's worth providing that in the standard library.

(We do have an MR_hash_float() function in the runtime system
which is used for tabling, though.)

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list