develooper Front page | perl.perl6.language | Postings from May 2005

Re: Roles and BUILD

Thread Previous | Thread Next
Larry Wall
May 16, 2005 08:55
Re: Roles and BUILD
Message ID:
On Mon, May 16, 2005 at 03:10:10PM +0000, Ingo Blechschmidt wrote:
:   my MyBot $bot .= new; 
:   # Are IRC::Bot::JoinOnInvite::BUILD and 
:   # IRC::Bot::SayHelloOnJoin::BUILD called? 

Yes, role BUILD submethods are magically composed into the class's
BUILD method somehow (or at least called at the appropriate time).

: And: 
:   my IRC::Bot $bot .= new; 
:   # Up to now, no BUILDs of any role is called. 
:   $bot does IRC::Bot::SayHelloOnJoin; 
:   # Is IRC::Bot::SayHelloOnJoin's BUILD called now? 

Seems like a reasonable thing in general.  If you're going to be
adding state to an object, it really ought to be initialized correctly
(though in this case you seem to be adding the state outside the
object itself, which is also fine).


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About