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

Re: Lexical environment of method

I am confused by your example, but if you want a lexical function
that references the instance variables of an instance, you just have
the instance create the closure:

(defflavor widget
   (ivar "puzzle"))

(defmethod (setup-fn widget) ()
  (setf fn #'(lambda () ... what you want done...)))

(defmethod (use-fn widget) ()
  ... (funcall fn) ...)

If you really want top level defun-in-flavor, like:

(defun-in-flavor (fun widget) ()

then you can try:

(defmethod (setup-fn widget) ()
  (setf fn #'(defun-in-flavor fun widget)))

(defmethod (use-fn widget) ()
  ... (funcall fn self sys:self-mapping-table) ...)