Hi Jingsong: does this make sense? It is a bit cryptic. -- Karl From discussion with Theo: it is a coincidence that we can generate all the code from the interface. This example is about composition of aspect interfaces. The interface class graph is: ProgramBehavior = List(ClassBehavior). ClassBehavior = List(ClassMethods) List(ClassName) AnyClass. ClassMethods = ClassName AnyClass. Program = List(ClassDef) ClassDef. ClassDef = Void. The first aspect interface: Int1(in ProgramBehavior, out methods:ClassMethods, out cn:ClassName, out AnyClass) from ProgramBehavior via [multiplicity 0..*] ClassBehavior bypassing methods:ClassMethods to {cn:ClassName, AnyClass} The second aspect interface: Int2(in cn:ClassName) cn:ClassName from prog:Program to [one path, multiplicity 1] def:ClassDef . addBehavior(methods) The third aspect interface: AnyClass from prog:Program to [multiplicity 0..*] ClassDef . addBehavior(methods)} Note: the multiplicity = 1 constraint will pick up the "find" method. ============================ Hi Theo: here is another aspect interface from collect.beh in DemeterJ. I would like to discuss this with you. We need a notation for this new aspect interface notation. Did you also look into more examples? -- Karl A nice short example. distributing methods to classes: * { } becomes {A,B,C} { } becomes A { } B { } C { } Aspect interface: from ProgramBehavior via [multiplicity 0..*] ClassBehavior bypassing methods:ClassMethods to { cn:ClassName from prog:Program . find(cn) def:ClassDef . addBehavior(methods), AnyClass from prog:Program to [multiplicity 0..*] ClassDef . addBehavior(methods)} Alternative: from ProgramBehavior via [multiplicity 0..*] ClassBehavior bypassing methods:ClassMethods to { cn:ClassName from prog:Program to [one path, multiplicity 1] def:ClassDef . addBehavior(methods), AnyClass from prog:Program to [multiplicity 0..*] ClassDef . addBehavior(methods)} Note: the multiplicity = 1 constraint will pick up the "find" method. All strategies must produce a non-empty TraversalGraph. Error aspect: if (def == null): no such class cn in prog Constraints in English: The bypassed methods must be a part in the cd and they are used in the computation later on. Note that the ClassMethods don't have to be an immediate part of Classbehavior. This aspect interface is so precise that we can generate code from it. The aspect interface notation uses nested traversals. Evolution step: Breaking the one path, multiplicity 1 constraint (e.g., having two paths of multiplicity 1) brings us back to the original. ===================== from ProgramBehavior via ClassBehavior bypassing ClassMethods to { ClassName, AnyClass } ClassBehavior: init methods ClassName AnyClass from ProgramBehavior via ClassBehavior: through collection transport from ClassMethods to ClassName and AnyClass view with arguments: from ProgramBehavior via ClassBehavior bypassing ClassMethods to {ClassName, AnyClass} what is bypassed (methods:ClassMethods) is picked up as an argument and used traversal: cn:Classname find(cn) ClassDef addBehavior(methods) void traversal: AnyClass Program.prog attachBehavior(methods) void: from Program to ClassDef: addBehavior(methods) Prospector: How many paths: from AnyClass want to call addBehavior(methods:ClassMethods) (traversal to an edge) Shows that global variables should be minimized. They create many more path opportunities. We want the traversal from AnyClass, using Program.prog, to ClassDef.addBehavior(ClassMethods methods) where methods is known at AnyClass to have exactly one path with a multiplicity of 0..* or x..* traversal: AnyClass Program.prog ClassGraph DList(ClassGraphEntry) Definition ClassDef addBehavior(methods) We want the traversal from ClassName, using Program.prog, to ClassDef.addBehavior(ClassMethods methods) where methods is known at ClassName to have exactly on path with multiplicity 1. traversal: host:ClassName Program.prog.findClassDef(ClassName).addBehavior(methods) error aspect: Actual traversal: ProgramBehavior DList(Behavior) ClassBehavior ClassGlobSpec now many paths OneClassGlob ClassGlob ClassnameGlob ClassNameExact ClassName AnyClass ClassGlobSet CommaList(ClassGlob) // collect.beh -- Behavior collection // $Id: collect.beh,v 1.1 1998/03/11 22:27:48 dougo Exp $ ProgramBehavior { /** Attach each behavior method to its class definition. */ void collectBehavior(String behfile) via ClassBehavior bypassing ClassMethods to { ClassName, AnyClass } { (@ ClassMethods methods; @) before ClassBehavior (@ methods = host.get_methods(); @) before ClassName (@ ClassDef def = Program.prog.findClassDef(host); if (def == null) { System.err.println(behfile + ": Error: No such class " + "\"" + host + "\"."); } else { def.addBehavior(methods); } @) before AnyClass (@ Program.prog.attachBehaviorToAllClasses(methods); @) } } Program { void attachBehaviorToAllClasses(ClassMethods methods) = allClassDefs { before ClassDef (@ host.addBehavior(methods); @) } } ClassDef { void addBehavior(ClassMethods methods) (@ if (classmethods == null) classmethods = new ClassMethods(); classmethods.concat(methods.deepCopy()); @) } ClassMethods { void concat(ClassMethods added) (@ if (added == null || added.methods == null) return; if (methods == null) methods = new Method_SList(); Enumeration e = added.methods.elements(); while (e.hasMoreElements()) methods.addElement((Method) e.nextElement()); @) }