Re: Is return statement ignored in advice?
"Michael" <[email protected]> Sun, 19 Aug 2007 15:13:39 -0400
| Newsgroups | gmane.comp.programming.aspect.general |
|---|---|
| Message-ID | <[email protected]> |
> Message: 4 > Date: Fri, 17 Aug 2007 23:58:14 +0200 > From: Bram Adams <[email protected]> > Subject: Re: [aosd-discuss] Is return statement ignored in advice? > To: Gregor Kiczales <[email protected]> > Cc: [email protected], chuan Zhao <[email protected]> > Message-ID: <[email protected]> > Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed > > Hi, > > Op 17-aug-07, om 19:35 heeft Gregor Kiczales het volgende geschreven: > >> In my experience, confusion about this comes up when people are >> thinking >> about AspectJ advice using a 'pre-processor' or 'code injection' >> semantic >> model. > > Not necessarily. At the SPLAT workshop during AOSD '07, we presented > a paper about an AOP implementation of idiom-based exception handling > in a huge C system (http://www.aosd.net/workshops/splat/2007/papers/ > adams.pdf). Our work was based around the notion of "local > continuation join point", i.e. a new kind of join point representing > the future of a program after conclusion of another join point J, but > constrained to J's enclosing execution join point. > > Consider a call to procedure g within a procedure f. The local > continuation join point L of the call to g models everything which > will happen inside f after the call to g returns. If one advises L > with around advice, then one is able to control whether the execution > of g is completed or not. In the latter case, one effectively stops > the execution of a procedure from within advice, but in a more fine- > grained way than around-advising a normal call or execution join > point allows. Major application of this is exception handling in C, > because aspects enhanced with local continuation join points can > express this in an easier to understand, more high-level way than > e.g. setjmp/longjmp. At the same time, implementation of the local > continuation join points is rather straightforward and can be made > efficient (http://users.ugent.be/~badams/aspicere2/). > > How does all this relate to this email thread? The combination "local > continuation join point + around advice" can actually be expressed > very succinctly by introducing a new keyword inside advice, inspired > by "break". If this statement is reached, both the advice as well as > the advised call join point's enclosing procedure are aborted (one > does not need to write a separate advice anymore on the call join > point's local continuation joinpoint). The guys of ACC (http:// > aspectc.msrg.utoronto.ca/ACC) applied this idea with their preturn() > construct, which is a return statement stopping both advice and base > procedure. > > Bottom line: attaching more semantics to a return statement inside > advice makes sense from a pure AOP perspective (as opposed to a > program transformation kind of view), especially in (but not limited > to) older languages like C. > > Kind regards, > > Bram Adams > GH-SEL, INTEC, Ghent University (Belgium) Following is an example of using preturn() in AspeCt-oriented C (ACC) from www.aspectc.net : /* core file */ int foo2(void) { printf("in foo2\n"); return 0; } int foo1(void) { printf("in foo1\n"); foo2(); printf("end of foo1\n"); return 0; } int main(void) { printf("return value of foo1 = %d \n", foo1()); return 0; } /* aspect file */ before(): call(int foo2()) { printf("before advice \n"); preturn(99); } /* execution result after applying the aspect */ >./a.out in foo1 before advice return value of foo1 = 99 Regards, Michael _______________________________________________ discuss mailing list - [email protected] To unsubscribe and change options, go to: http://aosd.net/mailman/listinfo/discuss_aosd.net Check out the AOSD.net Wiki: http://aosd.net/wiki