On Fri, 30 Apr 2004, Aldo Calpini wrote:

> so I wanted to explore the possible interoperability of wrappers and
> classes. another example I can think of:

>     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)

If further you said something like

        class Bar is Foo {...}

and wanted that to do Logging for Bar methods, that is a different
question. But since you'd have only so many classes saying

        class Bar is Foo does Logging {...}

isn't too much work, and this gives you the chance to control logging on a
class by class basis.

> cheers,
> Aldo

--Abhijit

Reply via email to