GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  MOOSEX::ARRAYREF (3)

.ds Aq ’

NAME

MooseX::ArrayRef - blessed arrayrefs with Moose

CONTENTS

SYNOPSIS



  {
    package Local::Person;
    use Moose;
    has name => (
      is    => ro,
      isa   => Str,
    );
    __PACKAGE__->meta->make_immutable;
  }
 
  {
    package Local::Marriage;
    use MooseX::ArrayRef;
    has husband => (
      is    => ro,
      isa   => Local::Person,
    );
    has wife => (
      is    => ro,
      isa   => Local::Person,
    );
    __PACKAGE__->meta->make_immutable;
  }
 
  my $marriage = Local::Marriage->new(
    wife      => Local::Person->new(name => Alex),
    husband   => Local::Person->new(name => Sam),
  );
 
  use Data::Dumper;
  use Scalar::Util qw(reftype);
  print reftype($marriage), "\n";   # ARRAY
  print Dumper($marriage);



DESCRIPTION

Objects implemented with arrayrefs rather than hashrefs are often faster than those implemented with hashrefs. Moose’s default object implementation is hashref based. Can we go faster?

Simply use MooseX::ArrayRef instead of use Moose, but note the limitations in the section below.

The current implementation is mostly a proof of concept, but it does mostly seem to work.

BUGS AND LIMITATIONS

    Limitations on Speed

The accessors for mutable classes not significantly faster than Moose’s traditional hashref-based objects. For immutable classes, the speed up is bigger



               Rate  HashRef_M ArrayRef_M  HashRef_I ArrayRef_I
  HashRef_M  1016/s         --        -1%       -48%       -55%
  ArrayRef_M 1031/s         1%         --       -47%       -54%
  HashRef_I  1953/s        92%        89%         --       -13%
  ArrayRef_I 2257/s       122%       119%        16%         --



    Limitations on Mutability

Things will probably break if you try to modify classes, add roles, etc on the fly. Make your classes immutable before instantiating even a single object.

    Limitations on Inheritance

Inheritance isn’t easy to implement with arrayrefs. The current implementation suffers from the following limitations:
o Single inheritance only.

You cannot extend multiple parent classes.

o Inherit from other MooseX::ArrayRef classes only.

A MooseX::ArrayRef class cannot extend a non-MooseX::ArrayRef class. Even non-Moose classes which are implemented using arrayrefs. (Of course, all Moose classes inherit from Moose::Object too, which is just fine.)

Note that delegation (via Moose’s handles) is often a good alternative to inheritance.

    Issue Tracker

Please report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=MooseX-ArrayRef>.

SEE ALSO

Moose, MooseX::GlobRef, MooseX::InsideOut.

AUTHOR

Toby Inkster <tobyink@cpan.org>.

COPYRIGHT AND LICENCE

This software is copyright (c) 2012 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

DISCLAIMER OF WARRANTIES

THIS PACKAGE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 MOOSEX::ARRAYREF (3) 2014-09-10

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.