libera/#commonlisp - IRC Chatlog
Search
1:45:25
Josh_2
Does anyone have an example of using multiple :around methods combined with call-next-method?
1:45:53
Josh_2
I only just realized that call-next-method when inside of an :around looks for the next most applicable :around method before executing the primary (by default) :facepalm:
2:21:23
zacque
Josh_2: You can play around with it using hierarchical classes like animal, dog, poodle, cat, persian-cat
2:22:23
zacque
Then define a generic function like MAKE-SOUND or PRINT-NAME for specialising it on different classes
2:24:18
zacque
The trick in understanding the `Standard Method Combination` is to understand the interplay of "shadowing" and "accumulative" effects for both primary and auxiliary methods
2:25:29
Josh_2
I though (call-next-method) invokes the primary method when in :around, but it doesn't, it looks for the next most applicable :around and if it doesn't find one then it calls the most applicable primary
2:27:41
zacque
Also, I suppose you can always define a "non-crazy" order with DEFINE-METHOD-COMBINATION
2:28:34
Bike
but usually if i don't understand a method combination thing i just figure out what the form looks like based on the method combination definition
2:30:11
Bike
like if your applicable methods are two arounds, two primaries, a before, and an after, what you get is (call-method #<around1> #<around2> (make-method (progn (call-method #<before>) (multiple-value-prog1 (call-method #<primary1> #<primary2>) (call-method #<after>)))))
2:31:00
Bike
in other words, if you use call-next-method and the next method is an around, you call that, but otherwise you call the whole before/primary/after situation
2:35:06
Bike
if you get this system https://github.com/sellout/method-combination-utilities you can use method-combination-expand to get that tree i wrote out manually