[aosd-discuss] can you have interception w/o aop?

Roger Johansson roger.johansson at compona.com
Thu Apr 6 04:27:36 EST 2006


Hi, thanks for the sample.
what would it take in order to make that sample AOP?

Im just trying to find a clear definition on when something is AOP and when 
its not.

you have " (let ((fib (lambda (x)" which i guess is similair to a pointcut 
of the function "fib" ?
you have the redefined body of the function which i guess is similair to the 
advice / interceptor

what fundamental parts are that sample missing in order to be aop?

//Roger


----- Original Message ----- 
From: "Pascal Costanza" <pc at p-cos.net>
To: "Roger Johansson" <roger.johansson at compona.com>
Cc: <discuss at aosd.net>
Sent: Thursday, April 06, 2006 11:11 AM
Subject: Re: [aosd-discuss] can you have interception w/o aop?


>
> On 6 Apr 2006, at 09:03, Roger Johansson wrote:
>
>> Ok, I don't feel that Ive got any real clear answers to the  questions 
>> yet.
>>
>> 1) Can you have interception w/o aop?
>> Show me a pseudo code example of interception where the  interception 
>> code is
>> not modular in any way
>>
>> If your base code manually triggers some event , its not  interception , 
>> then
>> its delegation, right?
>> Atleast for me interception is when the base (source) code is  ignorant 
>> of
>> the interception mechanism.
>> and if the base source code is ignorant of that mechanism the  design is
>> modular, right?
>> thus, whenever you use interception you get AOP?
>
> Here is an example in Scheme:
>
> (define (fib x)
>   (if (< x 2)
>      1
>      (+ (fib (- x 1))
>         (fib (- x 2)))))
>
> #;> (let ((fib (lambda (x)
>                  (display "fib called")
>                  (newline)
>                  (fib x))))
>       (fib 5))
> fib called
> 8
>
> The local redefinition of fib provides what would be called a before 
> advice in AOP terms. The code embedded in the local redefinition is 
> "oblivious" in the sense that it doesn't have to change its call to  fib 
> in order to trigger the "advice".
>
> If you want to have a global effect, you have to use side effects:
>
> (let ((org-fib fib))
>       (set! fib (lambda (x)
>                   (display "fib called")
>                   (newline)
>                   (org-fib x))))
>
> #;> (fib 3)
> fib called
> fib called
> fib called
> fib called
> fib called
> 3
>
> If you're looking for a more object-oriented style, you can get 
> interception by simply using something like the Decorator pattern.  Also 
> interesting are dynamic proxies in Java, the handling of  "message not 
> understood" errors in Smalltalk or method wrappers in  Smalltalk. There 
> are probably countless other approaches.
>
>
> Pascal
>
> -- 
> Pascal Costanza, mailto:pc at p-cos.net, http://p-cos.net
> Vrije Universiteit Brussel, Programming Technology Lab
> Pleinlaan 2, B-1050 Brussel, Belgium
>
>
>
> 




More information about the discuss mailing list