help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Object identity


From: Barry Margolin
Subject: Re: Object identity
Date: Tue, 21 Oct 2003 16:19:59 GMT

In article <jwvekx67ex4.fsf-monnier+gnu.emacs.help@vor.iro.umontreal.ca>,
Stefan Monnier  <monnier@iro.umontreal.ca> wrote:
>I still have no clue what it's useful for, so I tend to find such research
>rather pointless.  But I'm probably just missing the point.

The OP explained what it's useful for: emulating weak hash tables in a
system that doesn't have them built in.  If you use ordinary hash tables,
then using an object as a key will prevent it from ever becoming garbage,
which is like a memory leak.

If implementing an identity function like the one the OP requests results
in every object being larger (due to a design like the one I described),
it's likely that this overhead will be much greater than the memory leak in
his application.  So the net result is that he would be better off letting
the memory leak.

Another possibility is to implement an application-specific object-identity
function.  If all the objects that the application needs to deal with are
implemented as lists or structures, he can add an id-code slot to all of
them.  The object-identity function can maintain a counter, and store the
current value into this slot into the object if it's not filled in yet.
This way, the overhead cost is only paid for the few objects that need it,
rather than every Lisp object.

-- 
Barry Margolin, barry.margolin@level3.com
Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]