Re: sxhash and object identity



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))
))
.



Relevant Pages

  • sxhash and object identity
    ... actually return a new array rather than succeeding at expanding the provided one. ... I'm using (sxhash array) for such a purpose, ... Is there a way to get at the object identity, ...
    (comp.lang.lisp)
  • (part 45) Han from China answers your C questions
    ... instance of an object of type T can be thought of as an array of one ... For the purpose of address arithmetics - yes, ... Ah, but dear Tarasevich, that is why I put the emphasis on ... "For the purposes of these operators, a pointer to an object ...
    (comp.lang.c)
  • (part 45) Han from China answers your C questions
    ... instance of an object of type T can be thought of as an array of one ... For the purpose of address arithmetics - yes, ... Ah, but dear Tarasevich, that is why I put the emphasis on ... "For the purposes of these operators, a pointer to an object ...
    (comp.lang.c)
  • (part 45) Han from China answers your C questions
    ... instance of an object of type T can be thought of as an array of one ... For the purpose of address arithmetics - yes, ... Ah, but dear Tarasevich, that is why I put the emphasis on ... "For the purposes of these operators, a pointer to an object ...
    (comp.lang.c)
  • Re: (part 45) Han from China answers your C questions
    ... instance of an object of type T can be thought of as an array of one ... For the purpose of address arithmetics - yes, ... "For the purposes of these operators, a pointer to an object ... The rule in English is that a relative clause modifies the most recent ...
    (comp.lang.c)