Dearest Monks, I use Math::Vector::Real with XS (I'll refer to it as MVR) as a core dependency of my molecular object system. MVR exports the function V that creates the MVR object (a vector of numbers that has useful methods). e.g. atomic coordinates are MVR objects. My classes use the methods of MVR within a Role. Instances of my classes use the V function:
my $atom = Atom->new(Z=> 80, coords => [V(0,0,0), V(1,1,1), V(2,2,2)]) +;
creates a mercury atom with three MVR coordinates. The coords attribute is an ArrayRef-MVR with Array traits; I push_coords, get_coords, set_coords etc. I have two goals: 1. be able to use MVR's V function without having to add use Math::Vector::Real to every script. 2. be able to add MooseX::Storage capabilities for MVR to my classes. So I'm trying to subclass MVR:
package MyMVR; #ABSTRACT: Moose subclass of Math::Vector::Real use 5.008; use Moose; use namespace::autoclean; use MooseX::NonMoose; use MooseX::Storage; with Storage ('io' => 'StorableFile' ); extends 'Math::Vector::Real'; __PACKAGE__->meta->make_immutable; 1;
now using MVR->new works,
use MyMVR; my $a = MyMVR->new(0,0,0); my $b = MyMVR->new(1,1,1); print $_ ."\n" foreach (@{$a - $b});
with Moose warnings (that make sense) about MyMVR's new: "The new() method for MyMVR expects a hash reference or a key/value list. You passed an odd number of arguments at MyMVR_test.pl". The V function is no longer accessible. Any help achieving either goal is greatly appreciated! D

In reply to subclassing Math::Vector::Real with MooseX::NonMoose by docdurdee

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.