Re: sxhash and object identity
- From: Andrew Philpot <philpot@xxxxxxx>
- Date: 21 Nov 2005 18:06:57 GMT
In article <437f66fb$0$38046$5a6aecb4@xxxxxxxxxxxxxxxxx>, verec wrote:
> For debugging purposes, I'm trying to monitor when adjust-array does
> actually return a new array rather than succeeding at expanding the
> provided one.
>
> I'm using (sxhash array) for such a purpose, but I don't think
> that's entirely adequate as even though the array might not
> be changed, sxhash seems to report a different number each
> time I modify (add to) the array, which kind of makes sense
> for a hash value.
>
> Is there a way to get at the object identity, just for display
> purpose? (ie: the fact that this value could be implementation
> dependant is just irrelevant)
>
> Something along the lines
>
> (defun address-of (object)
> ( ...
>
> The CLHS only defines the identity function as, well, something
> that returns its argument (hit and miss 1) , and the word "address" is
> not even in
> the index ... (hit and miss 2) ... :(
>
> Many Thanks.
This is old, non-portable and incomplete. You might be able to extend
it using some internals from (PRINT-UNREADABLE-OBJECT :IDENTITY T).
Indeed, maybe PRINT-UNREADABLE-OBJECT is sufficient for your purpose,
and it's portable too. Note that current storage location address
isn't the same as object identity given the possibility for objects to
be relocated during GC. -- Andrew
;;;;;
;;;
;;; OBJECT-INTERNAL-POINTER
;;;
;;; Map from arbitrary objects to integers, suitable for unique ids.
;;; Note: All of the following were gleaned from Victoria Day PCL
;;; sources.
;;;
;;;;;
(defun object-internal-pointer (object)
"Given an arbitrary object, return an integer (should be fixnum in
many cases, unknown how Xerox and Gold Hill deal with this) which is
unique to that object, generally its actual pointer address"
(flet ((abut (x y)
(+ y (* x (expt 10 (1+ (floor (log y 10))))))))
#+CMU 0
#+(AND EXCL (NOT (AND ALLEGRO-VERSION>= (VERSION>= 5 0))))
(excl::pointer-to-fixnum object)
#+(AND EXCL ALLEGRO-VERSION>= (VERSION>= 5 0))
(excl::pointer-to-address object)
#+SYMBOLICS (si:%pointer object)
#+CORAL (ccl::%ptr-to-int object)
#+GOLD-HILL (multiple-value-call #'abut (sys:%pointer object))
#+HP (prim:@inf object)
#+IBCL (si:address object)
#+KCL (si:address object)
#+LUCID (lucid::%pointer object)
#+PYR 0
#+TI (si:%pointer object)
#+VAXL (system::%sp-pointer->fixnum object)
#+XEROX (abut (il::\\hiloc object) (il::\\loloc object))
))
.
- Follow-Ups:
- Re: sxhash and object identity
- From: Marcin 'Qrczak' Kowalczyk
- Re: sxhash and object identity
- From: Rob Warnock
- Re: sxhash and object identity
- From: verec
- Re: sxhash and object identity
- References:
- sxhash and object identity
- From: verec
- sxhash and object identity
- Prev by Date: Re: To be or not to be: the way of Lisp
- Next by Date: Re: How to find the rank of nth smallest element
- Previous by thread: Re: sxhash and object identity
- Next by thread: Re: sxhash and object identity
- Index(es):
Relevant Pages
|