[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: email@example.com
- Subject: Usefull Refcon
- From: Bill St. Clair <bill>
- Date: Wed, 15 Aug 90 11:51:37 -0400
- Cc: info-macl
- In-reply-to: Andrew L. M. Shalit's message of Tue, 14 Aug 90 19:04:18 -0400 <9008142304.AA04534@cambridge.apple.com>
Date: Tue, 14 Aug 90 19:04:18 -0400
From: Andrew L. M. Shalit <alms>
From: firstname.lastname@example.org (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).