Object-InsideOut - Migrating from Class::Std

Posted on Thu Nov 17 17:35:05 2005 by earl
Migrating from Class::Std
Is the :Init subroutine required? In a class that uses Class::Std, if the BUILD subroutine does not initialize a field, then the implicit new constructor will try to do a no-brainer initialization. When converting a module that uses Class::Std, I was getting an error message about Unhandled arguments. Adding an :Init subroutine made the problem go away. Does the Object::InsideOut module have a way to to simplify the following so the :Init subroutine is not needed?
my @myfield :Field; my %int_args :InitArgs = { 'myfield' => { 'Mandatory' => 1 } }; sub BUILD :Init { my ($self, $arg_ref) = @_; $self->set(\@myfield, $arg_ref=>{'myfield'} }
Someone who was indoctrinated with Class::Std may assume that functionality is there. It seems like the program could help me reduce trivial and redundant code. Thanks.
Direct Responses: 1339 | Write a response