+;; defines a slot-unbound method for class and slot-name, fills
+;; the slot by calling reader function with the slot values of
+;; the instance's reader-keys
+(defmacro def-lazy-reader (class slot-name reader &rest reader-keys)
+ (let* ((the-slot-name (gensym))
+ (the-class (gensym))
+ (the-instance (gensym))
+ (keys '()))
+ (dolist (key reader-keys)
+ (push (list 'slot-value the-instance (list 'quote key)) keys))
+ (setq keys (nreverse keys))
+ `(defmethod slot-unbound (,the-class (,the-instance ,class)
+ (,the-slot-name (eql ',slot-name)))
+ (declare (ignore ,the-class))
+ (setf (slot-value ,the-instance ,the-slot-name)
+ (,reader ,@keys)))))
+
+#+(or sbcl scl cmu)
+(defparameter *queued-definitions* nil)
+
+(defun process-queued-definitions ()
+ #+(or sbcl scl cmu)
+ (progn
+ (dolist (def *queued-definitions*)
+ (eval def))
+ (setq *queued-definitions* nil)))
+