2012-02-29

higher-order function programming

2.26: adda/aop/higher-order function programming:

. an example of AOP (aspect oriented prog'ing)
is a logger: you want every function to
log what it's doing .
. your job as a programmer is to
go into every new function and apply a recipe
for how to rewrite the function
so as to have it do this logging .
. in AOP, your job is to automate the
programming of that recipe
with something like this:

for each new function defined:
. if this function is recipe's target
(passes some tests like being of a certain type)
then search for some class of expressions,
and use list processing to modify the expression
(this is routinely done in lisp).

. just like you can find an expression with wildcards
(eg, find a function named f, with any params)
you can replace that find with something like
a declare block that includes f .
. this is the same way optimizations can be done;
and it could simplify the way
HLL-to-HLL compilers are designed
(these are compilers that translate one high-level lang
to another high-level lang, eg, adda lang -> C lang ).

No comments:

Post a Comment