[suby-talk] Comment on cut-based AOP
TRANS
transfire at gmail.com
Wed Oct 19 19:40:49 EDT 2005
I'm copynig this from the posting this from RCRchive comment in order
to discuss.
---
I am not opposed to AOP in Ruby. Nor am I opposed to the principle of
"cuts" for the implementation of AOP in Ruby. I however voted opposed
to the RCR in its current form due to a major flaw (in my mind) of the
current implementation of cuts.
The flaw is this: a cut made on a base class is always inserted
immediately under the base class in the inheritance heirarchy; that
is, advice from the cut is always imposed between the aspected classes
method and any redefinition/extension of that method in subclasses. In
my view of AOP, it should be possible to have the advice atomically
surround the method, no matter the depth below the actual cut point.
Take this (contrived) example:
class Foo
def name
"Foo"
end
end
class Bar < Foo
def name
"Bar < " + super
end
end
cut BracketName < Foo
def name
"[" + super + "]"
end
end
Bar.new.name
In the current implementation, the advice is applied strictly to
Foo#name, including the call to super from Bar#name. Result:
"Bar < [Foo]"
In some cases this is fine, but in other cases I would expect the
advice to be applied around the call to Bar#name with the internal
call to super (Foo#name) untouched, yielding:
"[Bar < Foo]"
In order to vote in support of an implementation of AOP in Ruby, I
would require both versions of advice to be supported, with a
reasonable way of distinguising the two.
I *do* want AOP in Ruby, and like the concept of "cuts" you have
introduced here. Congratulations and many thanks for the work you've
done so far. If you expand the RCR to include the functionality
described above, I will gladly change my vote in favor of the RCR.
Jacob Fugal lukfugl at gmail.com
More information about the suby-talk
mailing list