From: basman
Subject: weird behaviour of equalp hash tables
Date: 
Message-ID: <1141878753.655629.324930@z34g2000cwc.googlegroups.com>
I'm running into a weird seeming-bug in Allegro lisp 6.2.  In the
following code, I create an equalp hash table and create two vectors
that are equalp, yet the hash table doesn't seem to consider them the
same.  Btw, the same bug doesn't happen if I just create the arrays
without fill pointers.  Is this a bug, or am I missing something about
the spec of equalp hash tables?
- Bhaskara


CL-USER(451): (setf h (make-hash-table :test #'equalp))
#<EQUALP hash-table with 0 entries @ #x21ab902a>
CL-USER(452): (setf v (make-array 1 :fill-pointer 0))
#()
CL-USER(453): (vector-push 'foo v)
0
CL-USER(454): (setf v2 (make-array 1 :fill-pointer 0))
#()
CL-USER(455): (vector-push 'foo v2)
0
CL-USER(456): (setf (gethash v h) 'bar)
BAR
CL-USER(457): (equalp v v2)
T
CL-USER(458): (gethash v2 h)
NIL
NIL
CL-USER(459):
From: Pascal Bourguignon
Subject: Re: weird behaviour of equalp hash tables
Date: 
Message-ID: <873bhsw1u5.fsf@thalassa.informatimago.com>
"basman" <········@gmail.com> writes:

> I'm running into a weird seeming-bug in Allegro lisp 6.2.  In the
> following code, I create an equalp hash table and create two vectors
> that are equalp, yet the hash table doesn't seem to consider them the
> same.  Btw, the same bug doesn't happen if I just create the arrays
> without fill pointers.  Is this a bug, or am I missing something about
> the spec of equalp hash tables?
> - Bhaskara

Looks like a bug to me.


> CL-USER(451): (setf h (make-hash-table :test #'equalp))
> #<EQUALP hash-table with 0 entries @ #x21ab902a>
> CL-USER(452): (setf v (make-array 1 :fill-pointer 0))
> #()
> CL-USER(453): (vector-push 'foo v)
> 0
> CL-USER(454): (setf v2 (make-array 1 :fill-pointer 0))
> #()
> CL-USER(455): (vector-push 'foo v2)
> 0
> CL-USER(456): (setf (gethash v h) 'bar)
> BAR
> CL-USER(457): (equalp v v2)
> T
> CL-USER(458): (gethash v2 h)
> NIL
> NIL
> CL-USER(459):


In clisp-2.38:

[32]> (setf h (make-hash-table :test #'equalp))
#S(HASH-TABLE :TEST EQUALP)
[33]> (setf v (make-array 1 :fill-pointer 0))
#()
[34]> (vector-push 'foo v)
0
[35]> (setf v2 (make-array 1 :fill-pointer 0))
#()
[36]> (vector-push 'foo v2)
0
[37]> 
(setf (gethash v h) 'bar)
BAR
[38]> (equalp v v2)
T
[39]> (gethash v2 h)
BAR ;
T
[40]> 


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

CAUTION: The mass of this product contains the energy equivalent of
85 million tons of TNT per net ounce of weight.