From: Peter Vanbroekhoven Date: 2005-10-20T00:30:11+09:00 Subject: Re: [RCR] Cut-based AOP On Wed, 19 Oct 2005, Jeff Wood wrote: > Although I see the power of the examples and the ideas, it seems like > it's a bit watered down compared to AspectJ or other Aspect > frameworks. > > Usually, the definition of cuts allow you to wrap many things at once... > > AspectJ ( for instance ) allows you to use wildcards in both the > object type and the method names that are getting wrapped. It allows > you to add general functionality ( like debugging logs or security > control ) very easily to chunks ( of any size, even all ) of your > application. > > I'd like to see something like that for Ruby, but I do think that your > idea is a good start. > > maybe something that allows cut to take some wildcards > > Cut.new( "FileLogging" ) do > > wrap_method( File, :any ) do |method, *args| > # do logging stuff > method.call( *args ) > # do more logging stuff > end > > end > > or instead of File ...simply > > wrap_method( IO, :any ) ... > ... > end > > which would turn around and add this cut to any object of that type ( > or a derivative ) of IO > > Anyways, just additional thoughts. Shouldn't be too hard to implement > as objects now within Ruby as it exists... > > The only trick is catching overrides and new types that are defined > AFTER the cut has been added. > > ... just my $0.02US Thanks for contribution ;-) Well, I think we are aware of this. Cuts provide the basis of AOP, namely the basic wrapping functionality, and providing a convenient handle to the wrapping methods. These things can then be used in a full-fledged AOP library that provides wildcards and all. But I think the important point is that we think that cuts are a good basis for AOP. Anything on top of that is sugar. And because cuts fit well within Ruby's OO system, it will be good sugar! Peter