On Mon, Aug 30, 2004 at 12:17:57PM -0500, Abhijit Mahabal wrote:
> Another example to clarify what I am getting at:
> 
> Role Log2File  [: $filename] { method do_the_logging  {...}; ... }
> Role Log2Email [: $address ] { method do_the_logging  {...}; ... }
> Role Log2Tk    [: $widget  ] { method do_the_logging  {...}; ... }
> 
> Role SimpleLog {
>       method log( $msg ) { .do_the_logging( $msg ) }
> }
> 
> Role PoeticLog {
>       my sub make_into_poem {...}
>       method log( $msg ) {
>               .do_the_logging( make_into_a_poem( $msg ) );
>       }
> }
> 
> 
> Class Poem does PoeticLog does [EMAIL PROTECTED] {...}
> 

[ deletia ]

> In the example above, PoeticLog does not want to define the method
> .do_the_logging, but needs it to have been defined by somebody anyway.
> 
> To reiterate my question with this new example, "Can PoeticLog somehow
> ensure that somebody has defined .do_the_logging?"

Hmm.  So you want to check immediately after class/object composition
time that the class/object has a do_the_logging routine?

I didn't see any mention of this in a quick search through the
Apocalypses, but surely you can apply PRE and POST to roles. I.e.

role PoeticLog {
    ...
    POST { exists &do_the_logging }
}

would "fire" at class/object composition time.  (PRE would fire just
before composition, POST immediately after).  I seem to recall
something like this for classes too (though I may have imagined it)
where PRE blocks would fire immediately upon instantiation, and POST
blocks immediately after instantiation.  Er, perhaps the terminology
is wacky there.  The instantiation process goes PRE,BUILD,POST and
doesn't actually happen unless all of those happen.

-Scott
-- 
Jonathan Scott Duff
[EMAIL PROTECTED]

Reply via email to