On Fri, Apr 30, 2004 at 06:00:27PM +0200, Aldo Calpini wrote: : role Logging { : POST { : foreach ( ::_.meta.getmethods() ) -> $method { : $method.wrap( { : log($somewhere, "calling $method"); : call; : log($somewhere, "called $method"); : } ); : } : } : : class Foo does Logging { ... } : : does something like this make sense?
Maybe, except that POST is for DBC, and is expecting you to return a boolean value. I have no idea who will call the POST block when, if you put it on a class. It might be called after every method on every object, given that people will probably intend it to be taken as an invariant that must always hold for the class. So what you really want is LEAVE. Except that probably fires off when the role closure is left, rather than the class closure. Remember that things like POST and LEAVE are officially properties on the current block, not methods. And in fact, they aren't properties in themselves, but merely add their closure to a queue that is stored in a property, which probably ends up getting called internally with a .LEAVEALL or some such, if there's any method name involved at all. Larry