Subject: Re: IDENTITY-OF function
From: Erik Naggum <>
Date: Wed, 13 Feb 2002 17:24:16 GMT
Newsgroups: comp.lang.lisp
Message-ID: <>

* Will Fitzgerald
| For various reasons -- mostly having to do with serializing Lisp data or
| remote procedure calls -- it seems useful to have an 'identity-of'
| function which returns a (unique) identity for a Lisp object.

  The Lisp object _is_ its identity, so identity-of is already implemented:
  it is the function identity.

| If identity is true, the output from forms is followed by a space
| character and a representation of the object's identity, typically a
| storage address.

  That is only (intended to be) useful for debugging purposes.

| 1. Are there implementation specific functions that do what I want?

  Well, you can get the address of a Lisp object in most implementations,
  but what good will it do?  Even when you use print-unreadable-object,
  there is no guarantee that the identity will actually remain the same
  over any period of time.  Most Common Lisp implementations utilize a
  memory management system that can move objects around in memory.

| 2. Do you think the following (which returns the identity as a string)
| is reasonably portable?

  If you want portable, use an eq hashtable that maps to a unique numeric
  object identifier that you request for each object.  Note that this
  entangles you in the annoying object ownership protocol business.  You
  may get around this problem with a weak key.  A bidirectional hashtable
  does not exist, so you may have to use another with the identifier as key
  and a weak value, instead.

  If you need this for RPC, what good is the "identity" if it is not
  understood on the other side of the communication?  I must be missing
  something important here.

  In a fight against something, the fight has value, victory has none.
  In a fight for something, the fight is a loss, victory merely relief.