[erlang-questions] Instrumentation
Richard O'Keefe
ok@REDACTED
Mon Dec 5 00:41:25 CET 2011
On 3/12/2011, at 8:58 AM, Tim Watson wrote:
> The purpose of this prototyping was to play around with some of the ideas in Aspect Oriented Programming, and the library allows you to write code that executes before, after or around an annotated function.
TOPS-20 Interlisp, 1981, chapter 19: ADVISING.
I'm fairly confident the advice package was mainly
the work of Warren Teitelman.
Designed and implemented by Warren Teitelman.
If you start with
(LAMBDA arguments body)
advising gives you
(LAMBDA arguments (PROG (!VALUE)
(SETQ !VALUE (PROG NIL
before-advice-1
...
before-advice-n
(RETURN body)))
after-advice-1
...
after-advice-m
(RETURN !VALUE)))
except that the versions of PROG, SETQ, and VALUE used are
special ones so that macros cannot clobber them.
(ADVISE function [when [where]] what)
function is the function to advise, it could be a name
or (f-1 IN f-2), or some other things;
when is BEFORE, AFTER, or AROUND;
where is LAST, BOTTOM, or END (put after existing
advice, FIRST or TOP (put before existing advice),
or an editor command;
what is the code to be run, and for AROUND advice it
may include a * as an expression, showing where the
existing code is to be plugged.
It is important to give credit for ideas where it is really due.
It is possible that someone else may have had the advice package
idea before Warren Teitelman and the rest of the INTERLISP crew,
but it's the first publication of the idea I've ever seen, and
long predates all the hoopla about Aspect-Oriented Programming.
(As indeed does Erik Sandewall's writing about what he called
'insertive programming'.)
Before, after, and around advice is very handy, especially for
debugging. I'm delighted to see it becoming available for
Erlang. But credit where credit's due, eh?
More information about the erlang-questions
mailing list