From: Kent M Pitman
Subject: Re: advice?
Date: 
Message-ID: <sfwyb3cmm9s.fsf@world.std.com>
"advice" is an encapsulation mechanism used on lisp machines that allows
a mechanism similar to method combination for attaching additional
operations before, after, around, etc. an existing function.

the function TRACE can be modeled as a function which has "advice"
telling it to print some values before entry and upon return.

the useful thing about advice is that it attempts not to be order
dependent, so that unlike by-hand advice like:

 (let ((old-foo #'foo))
   (setf (symbol-function 'foo)
         #'(lambda (...) 
              ...do new stuff, then maybe call old-foo...)))

(which cannot be trivially undone because the you don't have 
inspection mechanisms allowing you to recognie this particular
FOO closure in some way that distinguishes it from others, or 
allows you to find the old-foo within #'foo), you CAN undo advice
and in fact you don't even have to undo it in the same order
as you defined it.

advice usually also has a "tag" that allows multiple pieces
of advice to be positioned in the same place (unlike multiple
:after methods on the same class, which would clobber each other)
and even a numeric "priority" so that when multiple things are
going to hit the same place, you can say which ought to come first
in the same kind of fuzzy way that process priorities let you
say what goes first in scheduling.

the reason advice is not part of CL is that it is generally regarded
as a debugging means and its action is often quite heuristic (e.g.,
because the notion of priorities is hard to make precise).  CL (post
1984) has been extended in various ways, but largely has shied away
from extensions into the "environment" and preferring to leave that to
implementations to sort out; most extensions post 1984 are linguistic
in nature.