Slightly more on capi:execute-with-interface ...
Hello,
Nick was gracious enough to help me with my previous question about
capi:execute-with-interface, and I've used his solution with success.
Basically, my problem was capturing the return value from the function
called by execute-with-interface.
Nick suggested this function as a model for what I should be doing ...
(defun frob (function interface)
(let ((result))
(capi:execute-with-interface interface
(lambda ()
(setf result
(list (funcall function)))))
(mp:process-wait "frobbing"
(lambda () result))
(car result)))
I modified this slightly to this:
(defun frob (interface function &rest args)
(let ((result))
(capi:execute-with-interface interface
(lambda ()
(setf result (apply function args))))
(mp:process-wait "frobbing"
(lambda () result))
result))
Nick, note that in modifying your suggestion, I eliminated the call to
(list ...) and the subsequent (car result) to return the result. I don't
think this breaks anything, but I'd welcome any advice you have if this
is a mistake.
Finally, using my slightly-hacked version of Nick's solution, I can now
write my interface accessors like this:
(defmethod reply-text ((self question-ui))
(frob self #'(lambda (self) (text-input-pane-text (reply self))) self))
(defmethod (setf reply-text) (text (self question-ui))
(frob self #'(lambda (self text) (setf (text-input-pane-text (reply self)) text)) self text))
In summary, this has worked out well, and resolved my problem. Thanks for
the help.
John Sambrook