D
Dave Weaver
I'm experimenting with using Class::Std to implement 'inside-out'
objects.
In the 'normal' style Perl objects, it's traditional for the
constructor to return undef if the construction fails. In Class::Std
the user-level meat of the construction phase is put in the BUILD
method, but in reading the docs I see no way that the BUILD method can
pass back a failure status (other than by die-ing) to the code that
wants to constuct the object.
For example, using old-style Perl objects,
my $obj = MyFileObject->new({ file => 'test.txt' });
would return undef if, for example, the passed file couldn't be found.
What is the correct way to do this construct-time checking using
Class::Std? Do I have to override new() ?
objects.
In the 'normal' style Perl objects, it's traditional for the
constructor to return undef if the construction fails. In Class::Std
the user-level meat of the construction phase is put in the BUILD
method, but in reading the docs I see no way that the BUILD method can
pass back a failure status (other than by die-ing) to the code that
wants to constuct the object.
For example, using old-style Perl objects,
my $obj = MyFileObject->new({ file => 'test.txt' });
would return undef if, for example, the passed file couldn't be found.
What is the correct way to do this construct-time checking using
Class::Std? Do I have to override new() ?