From: Trans Date: 2005-10-20T01:41:58+09:00 Subject: Re: [RCR] Cut-based AOP Eric Mahurin wrote: > Right now you can actually manually do something like the > above: > > class C > def foo;"foo";end > end > > c = C.new > > c.foo # => "foo" > > class C > foo1 = instance_method(:foo) > define_method(:foo) { "{"+foo1.bind(self).call+"}" } > end > > c.foo # => "{foo}" > > class C > foo1 = instance_method(:foo) > define_method(:foo) { "["+foo1.bind(self).call+"]" } > end > > c.foo # => "[{foo}]" > > Pretty sweet, huh? I wasn't sure if foo1 kept the previous > definition until I tried it, but apparently it does. > > Maybe just an easier way to do the above is all that is needed. > I think the above covers what is really needed for AOP - and > we already have it. Just simpler syntax is needed IMO. No > extra baggage needs to be added to the class data structures. Peter covers this well in his repsonse. I just want to point out one additional thing about using a Cut rather using simple method hooks: *introduction*. Using Cuts will allow you to conveniently store information (i.e. state) pertaining to that cut/aspect independent of the class being cut --an important criterea for good AOP. Presently class instance vars are what you'd use for this, but as Ruby comes to support local instance varaibles and/or methods introduction will become even better. > I'm not sure why you guys made such a lengthy RCR. I think I > have the concept now, but with all of the verbosity, it makes > it difficult to figure out what you are really proposing. I > think a much more concise RCR would have been better. Granted there are some spots where we could have been a little more concise. But we wanted to be thurough, much like a white paper, rather then something just thought up of a few days ago and thrown up. We also hope the brief overwiew of AOP would be of benefit to those not so familar with AOP. Thanks, T.