[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Run Time manipulation of Common Lisp Places
- To: email@example.com (Macintosh Common Lisp)
- Subject: Run Time manipulation of Common Lisp Places
- From: firstname.lastname@example.org (Guillaume Cartier)
- Date: Wed, 23 Oct 91 11:20:03 -0400
One problem I have always had is trying to make general lisp
constructs that understand places. Here goes an example:
I want to define a new class EDITABLE-PLACE-DIALOG-ITEM that
displays a place (the value of a global variable, the slot value
of an instance, etc) and automaticaly updates it when the user
changes the text of the dialog item.
I found that these kind of problems reocur time and time again
when you try to devellop general macintosh interface classes.
The best solution I managed is the following:
(defun GET-PLACE (place)
(funcall (place-reader place)))
(defun SET-PLACE (place value)
(funcall (place-writer place)
(defsetf GET-PLACE set-place)
(defmacro PLACE (form)
(let ((value (gensym)))
:reader (function (lambda () ,form))
:writer (function (lambda (,value) (setf ,form ,value))))))
You can then simply call
:place (place *foo*))
:place (place (slot-value *bar* 'my-slot)))
This works great, but the drawback is that every place that I
define this way includes two compiled functions. This seems a bit
Did I miss something?
Does any of you had the same problems?
LACIM, Universite du Quebec a Montreal.
Bureau: (514) 987-4290