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

Usefull Refcon

   Date: Tue, 14 Aug 90 19:04:18 -0400
   From: Andrew L. M. Shalit <alms>

      From: blakem@world.std.com (Blake Meike)

      I'd like to be able to find the lisp object that belongs to some
      of the Mac 'objects' I have floating around my program.  A standard
      technique is to put the 'name' of the lisp object into the refcon
      of the Mac 'object'.  But how do I convince lisp that the value that
      I get out of the refcon is really an object.

   This is a very unsafe thing to do.  If a GC happens, your object
   will move and the address in the refcon will not be updated.

   The only safe way I can think of to do what you want is to keep
   a hash table mapping integers to objects.  Then you can put the
   integers in the refcon.


This is very much the way that MACL's window system does it.  There is
an alist that maps MAC window structures to MACL *window* instances.
If you have lots of objects, then a hash table makes more sense.
Instead of storing an integer in the Refcon, you can use the MAC
object itself as the hash key (making sure not to store derefenced
handles, which can move).