There are times when one wants to be able to guard a method’s execution. A typical case is for callbacks, where we only want the callback to run under certain circumstances – but it’s easier to write the callbacks themselves as though they’ll always be called.
Object-oriented programs typically use a pattern for this: they split the function into two methods, one for the guard and one for the action being guarded. A sub-class can then override the guard independently of the action, and some sub-classes may override both guard and action.
This splitting seems a little awkward, though, and there are times when I’d prefer to have everything (guard and action) defined as part of the one method. Fortunately there’s a Lisp-ier solution involving defining a new method combination to get exactly this behaviour.
CLOS , unlike most languages, allows a programmer to control how methods are combined in terms of overriding. The “standard” combination allows for :before, :after, and :around methods as well as undecorated “primary” methods.