On Sun, 19 Aug 2018 10:25:44 +0100 Chris Vine <[email protected]> wrote:
> On Sun, 19 Aug 2018 03:40:26 +0200 > Thomas Chust <[email protected]> wrote: > > [...] > > Then I realized that eq?-hash simply cannot be called on certain types > > of objects: > > [...] > > $ csi > > CHICKEN > > (c) 2008-2018, The CHICKEN Team > > (c) 2000-2007, Felix L. Winkelmann > > Version 5.0.0rc1 (prerelease) (rev 9d480412) > > linux-unix-gnu-x86-64 [ 64bit dload ptables ] > > > > #;1> (import srfi-69) > > ; loading /opt/chicken/lib/chicken/9/srfi-69.import.so ... > > ; loading /opt/chicken/lib/chicken/9/srfi-69.so ... > > #;2> (eq?-hash 2/3) > > [panic] out of memory - heap has reached its maximum size - execution > > terminated > > [...] > > It probably shouldn't crash, but since '(eq? 2 2)' is allowed to evaluate > to #f, depending on the implementation, does it matter that much? (Maybe > crashing is better than a hash function silently failing to produce a > workable hash.) > [...] Hello, this matters a lot: For one I have an application where it is crucial to be able to identify if the exact same object is passed more than once into certain functions and to be able to detect cyclic data structures – eq? and eq?-hash are supposed to be applicable to precisely that situation. Secondly, and maybe even more importantly, the implementation of eq?-hash in the srfi-69 egg seems to be based on that for eqv?-hash and equal?-hash in the case of non-immediate data objects: $ csi -R srfi-69 -p '(eqv?-hash 2/3)' [panic] out of memory - heap has reached its maximum size - execution terminated [...] $ csi -R srfi-69 -p '(equal?-hash 2+3i)' [panic] out of memory - heap has reached its maximum size - execution terminated [...] In other words, none of the hash functions offered by the srfi-69 egg are usable at all! And lastly, a hash function that goes with a certain equality predicate should always be applicable to the entire domain of the equality predicate to be of any practical value. Ciao, Thomas -- No woman should marry before she has slain her tenth man. -- Drow Proverb _______________________________________________ Chicken-users mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/chicken-users
