Those controlled manners are at least two:
three packages are used, but conceptually is just one class, so there is no messing with the internals of one class from another and the reblessing is always done from inside the class not from the outside.class TheHulk; sub new { bless $self, $class; $self->go_normal; $self; } sub go_normal { bless $self, TheHulk::_normal; } sub go_green { bless $self, TheHulk::_green; } sub relax {} sub make_angry {} package TheHulk::_normal; sub run { ... } sub make_angry { $self->go_green; } package TheHulk::_green; sub run { ... } sub relax { $self->go_normal; }
In reply to Re^4: Re-blessing || Re-constructing objects
by salva
in thread Re-blessing || Re-constructing objects
by blogical
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |