You don't want to: garbage collection may (and often does!) move objects, so the address of an object may be different between observations.
Another problem is posed by immediate objects (e.g., 1
or #\A
) - what would their addresses be?!
That said, ANSI CL offers the :identity
argument to
print-unreadable-object
which most lisps interpret to mean the current address in memory.
Alas, the output format is implementation-dependent (e.g., SBCL wraps
the address in {}
), so it is better to find the
implementation-specific function which returns the address.
Using apropos
, we easily find
system::address-of
in CLISP;
sb-kernel:get-lisp-obj-address
in SBCL.
PS. Check out sxhash
- could
that be what you are looking for?