> >     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?
>
> Sure, but where is inheritance involved here? Roles are composed into
> classes, not inherited from. (That particular Role seems to be messing
> with the class though.. its a trait rather than a role... and it will have
> to be processed *after* all methods in the class are known (including
> those that come from other roles)... all that may render what I say below
> meaningless)

Oops, I had missed the POST{}. Sorry about that. Maybe that renders your
code workable! But let me understand this:
        The POST block will be composed into the Class{...} block and
would be the last thing that runs. There could be timing issues though:
just when is the last block run? After all other class composition work?
What if there are two POST blocks? Can a POST add methods? Seems dangerous
to me, after the class has gone to all the trouble of making sure that a
class is sensibly composed, the POST may just mess things up.

Just some paranoid random thoughts...

--Abhijit

Reply via email to