in reply to subclassing Math::Vector::Real with MooseX::NonMoose

Firstly, Moose defaults to instances being blessed hashes; MVR seems to used blessed arrayrefs. So use MooseX::NonMoose::InsideOut instead of plain MooseX::NonMoose.

Secondly, you probably want to write a FOREIGNBUILDARGS method for your class. This translates the arguments passed to your class' constructor into a list of argument that the parent class' constructor expects.

Lastly, if you want to use this V function, then you'll need to import it into each namespace where you're using it:

use Math::Vector::Real qw(V);
use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name
/div

Replies are listed 'Best First'.
Re^2: subclassing Math::Vector::Real with MooseX::NonMoose
by docdurdee (Scribe) on Sep 12, 2013 at 15:52 UTC
    quickly adding this and MX::Nonmoose::InsideOut to MyMVR:
    sub FOREIGNBUILDARGS { return @{$_[2]}}
    @_ is (class, key (vec), and value (arrayref)) from the adjusted script:
    use MyMVR; my $a = MyMVR->new(vec=>[0,0,0]); my $b = MyMVR->new(vec=>[1,1,1]); print $_ ."\n" foreach (@{$a - $b}); print $a->dist($b) . "\n";
    which works. Thanks!