unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Barry Margolin <barry.margolin@level3.com>
Subject: Re: Object identity
Date: Tue, 21 Oct 2003 16:19:59 GMT	[thread overview]
Message-ID: <P0dlb.128$lK3.104@news.level3.com> (raw)
In-Reply-To: jwvekx67ex4.fsf-monnier+gnu.emacs.help@vor.iro.umontreal.ca

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	other threads:[~2003-10-21 16:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.2049.1066716515.21628.help-gnu-emacs@gnu.org>
2003-10-21 15:09 ` Object identity Stefan Monnier
2003-10-21 16:55   ` Stefan Monnier
2003-10-21 19:00   ` Lars Brinkhoff
     [not found]   ` <mailman.2095.1066762882.21628.help-gnu-emacs@gnu.org>
2003-10-21 19:27     ` Barry Margolin
2003-10-21 19:49       ` Lars Brinkhoff
     [not found]       ` <mailman.2101.1066765792.21628.help-gnu-emacs@gnu.org>
2003-10-21 19:56         ` Barry Margolin
2003-10-22  7:35           ` Lars Brinkhoff
2003-10-21 15:44 ` Barry Margolin
2003-10-21 16:09   ` Stefan Monnier
2003-10-21 16:19     ` Barry Margolin [this message]
2003-10-21 16:50       ` Stefan Monnier
2003-10-21 17:19         ` Barry Margolin
2003-10-21 17:42   ` Lars Brinkhoff
     [not found]   ` <mailman.2089.1066758667.21628.help-gnu-emacs@gnu.org>
2003-10-21 19:59     ` Stefan Monnier
2003-10-21 20:13       ` Lars Brinkhoff
     [not found]       ` <mailman.2104.1066767237.21628.help-gnu-emacs@gnu.org>
2003-10-21 21:22         ` Stefan Monnier
2003-10-21 21:39           ` Barry Margolin
2003-10-21  6:07 Lars Brinkhoff
2003-10-26 17:30 ` jan
2003-10-26 22:45   ` jan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='P0dlb.128$lK3.104@news.level3.com' \
    --to=barry.margolin@level3.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).