Re: CAPI and create-callback
On Tue, May 6, 2014 at 10:31 AM, Jeffrey Massung <massung@gmail.com> wrote:
>
> (defmethod my-capi-framework:create-callback :after ((pane my-output-pane-subclass))
> ...)
>
> This is what I have currently. It works fine, but feels strange to me. That said, I'm still not fully comfortable with CLOS generic method ordering (:before, :after, :around), and I don't understand what your example of 'progn' does.
One primary method together with only :after specializations for
subclasses is basically the same as the progn :most-specific-last
method combination, save for the return value. I chose progn because I
pictured the callbacks as a chain of equal-stature functions rather
than one specially designated function (the primary method) with
others sprinkled on top (aux methods), but it doesn't matter a whole
lot.
> Your initialize-instance idea is quite interesting as well. I agree that it feels like a last resort. But it's neat to see that it's possible that way.
In retrospect it's not that bad as long as it accomplishes what is
needed and the "switcheroo" move is noted (if only for yourself six
months from now).
> On a side note, something I've never figured out is how to remove a method in a 'chain'. For example, if I create an initialize-instance method :after, and later decide I don't want it, then the only options I've really had are to kill LW and restart the image or compile the method with an empty body. Is there something else I could do?
(defgeneric foo (x))
(defmethod foo ((x integer)) x)
(defmethod foo :after ((x integer)) (break "foo"))
(foo 3) ;=> break
(remove-method #'foo (find-method #'foo '(:after)
(list (find-class 'integer))))
(foo 3) ;=> 3
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html