[aspectl-devel] with-special-function-scope
ml13 at onlinehome.de
ml13 at onlinehome.de
Sat Nov 27 12:52:46 UTC 2004
Hi,
I am trying to extend the test example to use a special function that
is recursive.
As an example, I am defining f(x) to compute the sum of the squares
from 0 to x.
When I am trying to dynamically redefining the function to simply add 1
to its result, this new definition seems to get called "inside" as
well.
What do I have to do to get the (assert (eql (f 5) 56))) working??
I am using LispWorks MacOSX by the way.
Thanks for any help,
Peter.
PS: By the way, is there possibly any example existing of the cached
fibonacci function using the current version of aspectL?
-----------------
(progn
(define-special-function f (x)
(:definer f*))
(defmethod f* ((scope t) x)
(if (zerop x)
0
(+ (* x x)
(f (1- x)))))
(assert (eql (f 5) 55))
(with-special-function-scope (f*)
(defmethod* f* ((scope dynamic) x)
(1+ (call-next-method)))
(assert (eql (f 5) 56)))
(assert (eql (f 6) 91)))
More information about the Aspectl-devel
mailing list