[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: should hash function upper bound be exclusive?

This page is part of the web mail archives of SRFI 69 from before July 7th, 2015. The new archives for SRFI 69 contain all messages, not just those from before July 7th, 2015.



On Tue, Aug 09, 2005 at 10:31:29AM -0700, Per Bothner wrote:
> Current the 'bound' for hash functions is exclusive: the returned hash h
> is such that (and (>= 0 h) (< h bound)).  One might want the default
> bound to be such that hashes range over the positive fixnums.  But in
> that case the bound would not be a fixnum: it would have to be one
> larger than the largest fixnum.

I think this is an implementation detail.  If one wants hashes that
range over the positive fixnums, one should definitely not try to find
out the maximum fixnum and give that as a bound to (hash), but just use
(hash) without a bound -- that is, with the default bound.  The SRFI has
been written to account exactly for this situation (even if one can't
say anything very precise about it): it leaves for the implementation to
pick a good default bound when the user supplies none.

Besides, even if people did explicitly request a total-fixnumber-range
hash, it would do no harm to leave just a few fixnum values out.

So unless there are reasons like API intuitiveness for changing the
bound parameter to be inclusive, I'll refrain from making changes.

Panu

-- 
personal contact: atehwa@xxxxxx, +35841 5323835, +3589 85619369
work contact: panu.kalliokoski@xxxxxxxxxxx, +35850 3678003
kotisivu (henkkoht):	http://www.iki.fi/atehwa/
homepage (technical):	http://sange.fi/~atehwa/