[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing printnames

At  4:04 PM 9/30/93 +0000, M. Timur Friedman wrote:
 >I have noticed that objects will sometimes spontaneously change their
 >print names in MCL 2.0p2 on a MacIIx.
 >For example, I have a class of objects called answer-node.  I have not
 >defined a print-object method for answer-node. While my program is
 >running, it prints out statements such as:
 >  Moving node #<ANSWER-NODE #x4E21A1>
 >However, when I use the inspector later to look at the same object, it
 >is has a different name: #<ANSWER-NODE #x4DF259>.
 >My question is: is this a known behaviour?

Yes, this is known. The number beginning with #x is the memory address
of your object in hexadecimal, at the moment when its name is printed.

Because lisp programs manage memory automatically (called "garbage 
collection"), sometimes your objects will move around to new locations.
As a result, these numbers will change. This is perfectly normal, and
all data structures pointing to your nodes will continue to point
to them properly, no matter how much they move around.

You should not depend on identifying an object uniquely by its
memory location. You can always count on the EQ predicate to tell 
whether you have the same object, no matter how much it may have
been moved by the garbage collector.