On Mon, Oct 28, 2002 at 12:07:49PM -0800, David Hanley wrote:
> (deftype hash-type () '(unsigned-byte 32))
> 
> 
> (defparameter hash-code 0)
> (declaim (type hash-type hash-code))
> 
> (defun foo( x )
>   (declare (type hash-type x))
>   (setf hash-code (logxor hash-code x)))
> 
> this always gives me a warning :
> 
> note: doing unsigned work to integer conversion (cost
> 20) for: 
> the second argument of SET
> 
> it doesn't seem to matter if i make hash-type fixnum
> or not. 
> [...]
> fine, then the result is being unboxed for some
> reason?!?  

That's right. The result will have to be boxed to be stored in
hash-code, since it can be accessed from anywhere, and must look like a
lisp object.

If you require no boxing, you could store your hash-code in a
specialized vector of length one [created by (MAKE-ARRAY 1 :ELEMENT-TYPE
'(UNSIGNED-BYTE 32))]; that said, I don't see any boxing when HASH-TYPE
is FIXNUM; the disassemble output (from DISASSEMBLE) says:

; 090519F6:       MOV EAX, [#x90519D0]        ; 'HASH-CODE
                                              ; no-arg-parsing entry point
;      9FC:       MOV EAX, [EAX-3]
;      9FF:       XOR EAX, EDX
;      A01:       MOV ECX, [#x90519D0]        ; 'HASH-CODE
;      A07:       MOV [ECX-3], EAX
; [...]

Cheers,

Christophe
-- 
http://www-jcsu.jesus.cam.ac.uk/~csr21/       +44 1223 510 299/+44 7729 383 757
(set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b)))
(defvar b "~&Just another Lisp hacker~%")    (pprint #36rJesusCollegeCambridge)

Reply via email to