Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

print-object on hash-tables...

8 views
Skip to first unread message

David Bakhash

unread,
Jan 26, 1999, 3:00:00 AM1/26/99
to
I'm using ACL, and when I print out a hash-table, I get things like:

#<EQL hash-table with 0 entries @ #x9c221a>

This question really isn't only for hash-tables, as what I want to know
is what the:

@ #x9c221a

is for. I suppose it's the address of the hash-table, but I thought
that that would be useless to a Lisp programmer, so why would they tell
you that?

dave

Lyman S. Taylor

unread,
Jan 26, 1999, 3:00:00 AM1/26/99
to
In article <wk4spdl...@mit.edu>, David Bakhash <ca...@mit.edu> wrote:
...

>This question really isn't only for hash-tables, as what I want to know
>is what the:
>
>@ #x9c221a
>
>is for. I suppose it's the address of the hash-table, but I thought
>that that would be useless to a Lisp programmer, so why would they tell
>you that?

Perhaps ROOM tells you where the generations' "address" and size.
From that you may be able to figure out which generation your
"object" is in.

Secondly, you may be doing something funky with a FFI call or low
level debugger. Which is related to the next point.

It is also that object's "identity". Whether that notion of
"identity" is useful ( EQ , EQL) in your case may vary. It can
solve the "which" hash table question.
[ A couple of days ago I think I posted the expression
(make-array 4
:element-type 'class-a
:initial-element (make-instance 'class-a))

if the array prints in full then you can see it is an array of
the same instance since they all have the same "identity".
The fact that the "number" is the same is the relevant point. Not
so much that it is an particular location in memory. ]

In "day to day" usage when everything is functioning as planned, it
is probably superfluous.

--

Lyman S. Taylor "The Borg -- party poopers of the Galaxy. "
(ly...@cc.gatech.edu) EMH Doctor Star Trek Voyager.

Erik Naggum

unread,
Jan 27, 1999, 3:00:00 AM1/27/99
to
* David Bakhash <ca...@mit.edu>

| This question really isn't only for hash-tables, as what I want to know
| is what the: @ #x9c221a is for. I suppose it's the address of the
| hash-table, but I thought that that would be useless to a Lisp
| programmer, so why would they tell you that?

it is indeed the machine address of the object. this is what the
:IDENTITY argument to PRINT-UNREADABLE-OBJECT gives you.

(print-unreadable-object (nil nil :type t :identity t))
-| #<null @ #x20000985>

it is sometimes useful to know whether you have different somethings that
otherwise look exactly the same.

(make-hash-table)
=> #<eql hash-table with 0 entries @ #x21433aca>
(make-hash-table)
=> #<eql hash-table with 0 entries @ #x21433fd2>

the value is not necessarily useful across a garbage collection, so it
does have fairly limited use, but there's always something to be said for
visual inspection.

if you don't like it, the following piece of advice will turn it off.

(advise excl::print-unreadable-object-1 :before no-identity nil
(setf (fourth arglist) nil))

you will now observe this behavior, instead:

(print-unreadable-object (nil nil :type t :identity t))
-| #<null>

#:Erik
--
SIGTHTBABW: a signal sent from Unix to its programmers at random
intervals to make them remember that There Has To Be A Better Way.

Erik Naggum

unread,
Jan 27, 1999, 3:00:00 AM1/27/99
to
* ly...@cc.gatech.edu (Lyman S. Taylor)

| Perhaps ROOM tells you where the generations' "address" and size. From
| that you may be able to figure out which generation your "object" is in.

this is more accurately reported by POINTER-STORAGE-TYPE in Allegro CL.

0 new messages