in reply to Overriding arguments in Class::Std superclass constructors

Although not exactly what you want:
mysubclass->new({ myclass => { value = 23 }});
works. another solution would be to add a default value to myclass->value so that a missing initializer label does not throw a fatal error. To set a new default value, overriding the START method seems to work:
package myclass; use Class::Std; my %value :ATTR( :name<value> :default(1)); 1;
package mysubclass; use base qw(myclass); sub START { my ($self, $ident, $arg_ref) = @_; $self->set_value(123) if !defined $arg_ref->{value}; } 1;
UPDATE: original version ignored initializer labels.

Replies are listed 'Best First'.
Re^2: Overriding arguments in Class::Std superclass constructors
by fce2 (Sexton) on Aug 13, 2006 at 04:06 UTC
    Yeah, the first sucks because I'd have to do it everywhere I create objects, and all those places have to "know" more than they should.

    My workaround is basically the same, except that I removed the init_arg and made myclass::START do the croak-or-set itself.

    Thanks for the ideas. I've opened ticket 20966 in RT.