[aspectc-user] is args() redundant?

Olaf Spinczyk Olaf.Spinczyk at informatik.uni-erlangen.de
Thu Nov 14 15:48:01 CET 2002

Hi Dominik,

Am Donnerstag 14 November 2002 12:52 schrieb EXTERN Sacher Dominik (Diplomand; 
> Dear all!
> I don´t get the point of the "args()" - PCD.
> This is the status quo:
> pointcut irq_Level( int level ) = call ("void IRQ::level(int)") && args(
> level );
> advice irq_Level( level ) : after( int level ) { ... }
> But won´t this be sufficient:
> pointcut irq_Level( int level ) = call ("void IRQ::level(int)");
> advice irq_Level( level ) : after( int level ) { ... }

args("int") and args(level) select all call or execution join points with a 
single integer argument. args(level) does not only select these join points, 
it also binds the parameter 'level' to this argument as a context 

To use args(level) in conjunction with call("void IRQ::level(int)") leads to 
redundancy because both pointcut funtions restrict the set of selected join 
points to those having only a single integer argument. To avoid this 
redundancy you can use the following expression:

pointcut irq_Level(int level) = call("void IRQ::level(...)") && args(level);

The idea behind the args() function is to separate functions, which can bind 
context information, from 'normal' pointcut functions, which only select 
joinpoints. You are right that there may be some redundancy, but it can be 

Your proposed code fragment has the disadvantage that AspectC++ would have 
problems in a case with multiple arguments, e.g. "pointcut irq_Level( int 
level ) = call ("void IRQ::level(int,int,int)")"; Should "level" be bound to 
the first, second, or third argument? AspectC++ would be able to tell that.

Aspect*J* had a syntax like this in early versions:

 pointcut irq_Level( int mylevel ) = call (void IRQ.level(mylevel));

Later they switched to the args() function, just to separate context binding 
from join point selection.



More information about the aspectc-user mailing list