sub Listable::insert { my ($self, $child) = @_; die "Cannot insert ", ref($child), " into a ", ref($self) unless $self->is_legal_to_insert($child); push @{$self}, $child; } sub Listable::insert { return 1; } sub Matrices::is_legal_to_insert { my ($self, $child) = @_; return 1 if $child->isa( 'Matrix' ); return $self->SUPER::is_legal_to_insert( $child ); }