From leavens@cs.iastate.edu Sun Nov 9 22:57:16 2003 Date: Sun, 9 Nov 2003 22:56:52 -0600 (CST) From: Gary T. Leavens To: wfengm@cs.iastate.edu Cc: Staff for Com S 541 Subject: Re: HW4 Hi Fengming, On Sun, 9 Nov 2003 wfengm@cs.iastate.edu wrote: > I am not sure about what to do in this homework. > Should I give the syntactic type inference rules for the problem or semantics > rules as what we did for OO type system? Could you please give me a short > example for guide? More of the type rules like we showed for the simply typed lambda calculus. (We also looked at type inference rules for the OO langauges, as well as the semantics of type attributes. You don't have to defined detailed semantics for type attributes.) In essence you have to define something that will communicate clearly to me. An example: Context, x:T |- PointCut isOK, Context, x:T |- Body isOK ------------------------------------------------------- Context |- after() returning (T x) : PointCut { Body } isOK which would say something like the after advice in the conclusion type checks OK if, in the context augmented with the binding of x to the type T, the point cut checks OK and the body also checks OK. Of course, I think you'll need to have a more complicated notion of context and probably want a bit more generalized of a rule, but this is the kind of thing I'm thinking of. I once did it formally here, but one rule of AspectJ is that a proceed expression in the body of an around advice must have the same number and types of formal arguments as the method it surrounds. I think it's interesting challenge to formalize this. I'm not really sure what the right answer is for this problem; but I hope you'll learn something about type systems and about AspectJ. -- Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 ----------------------------- From leavens@cs.iastate.edu Wed Nov 12 00:00:12 2003 Date: Tue, 11 Nov 2003 23:58:11 -0600 (CST) From: Gary T. Leavens To: Computer Science 541 -- Brett Graves , com_s_541@cs.iastate.edu, Yogy Namara Subject: COMS 541: Slightly revised homework 5, correction about proceed() Hi all, I made some small technical corrections and clarifications again tonight in the statement of homework 5, so if you got a copy this afternoon, before now, you might want to look at the revision instead. I also wanted to point out that Shane Oldenburger was correct in his remark in class today about the type of proceed, and I was not. I said two things that were wrong about proceed. First I said that the type of the arguments to proceed was based on the joint point being executed. That is incorrect, it's based on the formal parameters to the around advice. Second, I said that the form proceed() was always type correct. That is incorrect, as Shane mentioned, you have to always pass the same number of arguments and the formal parameters given in the around advice. For example, consider the following: public aspect TestProceed { public pointcut intCalls(int k) : call(int *(int, ..)) && args(k, ..); // the following is legal int around(int l) : intCalls(l) { return proceed(l); } // the following is illegal int around(int l) : intCalls(l) { return proceed(); // type error here! } } It's interesting playing around with this that I have found three different typing rules for AspectJ. I think it's quite fruitful to play with things and try minor variations to see what type errors are provoked in the compiler. Then you might look up things in the semantics appendix of the AspectJ programmer's guide. -- Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580