• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

examples/H03-May-2022-8169

lib/MooseX/H03-May-2022-362181

t/H03-May-2022-11080

CONTRIBUTINGH A D10-Sep-20143.1 KiB8456

COPYRIGHTH A D10-Sep-20141.3 KiB5946

CREDITSH A D10-Sep-201457 42

ChangesH A D10-Sep-2014509 2616

INSTALLH A D10-Sep-2014969 3923

LICENSEH A D10-Sep-201417.9 KiB380292

MANIFESTH A D10-Sep-2014323 2423

META.jsonH A D10-Sep-20141.9 KiB7675

META.ymlH A D10-Sep-20141.2 KiB4443

Makefile.PLH A D10-Sep-20144.9 KiB142125

READMEH A D10-Sep-20143.3 KiB10682

SIGNATUREH A D10-Sep-20142 KiB4639

dist.iniH A D10-Sep-201464 32

doap.ttlH A D10-Sep-20144.6 KiB10090

README

1NAME
2    MooseX::ArrayRef - blessed arrayrefs with Moose
3
4SYNOPSIS
5      {
6        package Local::Person;
7        use Moose;
8        has name => (
9          is    => 'ro',
10          isa   => 'Str',
11        );
12        __PACKAGE__->meta->make_immutable;
13      }
14
15      {
16        package Local::Marriage;
17        use MooseX::ArrayRef;
18        has husband => (
19          is    => 'ro',
20          isa   => 'Local::Person',
21        );
22        has wife => (
23          is    => 'ro',
24          isa   => 'Local::Person',
25        );
26        __PACKAGE__->meta->make_immutable;
27      }
28
29      my $marriage = Local::Marriage->new(
30        wife      => Local::Person->new(name => 'Alex'),
31        husband   => Local::Person->new(name => 'Sam'),
32      );
33
34      use Data::Dumper;
35      use Scalar::Util qw(reftype);
36      print reftype($marriage), "\n";   # 'ARRAY'
37      print Dumper($marriage);
38
39DESCRIPTION
40    Objects implemented with arrayrefs rather than hashrefs are often faster
41    than those implemented with hashrefs. Moose's default object
42    implementation is hashref based. Can we go faster?
43
44    Simply `use MooseX::ArrayRef` instead of `use Moose`, but note the
45    limitations in the section below.
46
47    The current implementation is mostly a proof of concept, but it does
48    mostly seem to work.
49
50BUGS AND LIMITATIONS
51  Limitations on Speed
52    The accessors for mutable classes not significantly faster than Moose's
53    traditional hashref-based objects. For immutable classes, the speed up is
54    bigger
55
56                   Rate  HashRef_M ArrayRef_M  HashRef_I ArrayRef_I
57      HashRef_M  1016/s         --        -1%       -48%       -55%
58      ArrayRef_M 1031/s         1%         --       -47%       -54%
59      HashRef_I  1953/s        92%        89%         --       -13%
60      ArrayRef_I 2257/s       122%       119%        16%         --
61
62  Limitations on Mutability
63    Things will probably break if you try to modify classes, add roles, etc
64    "on the fly". Make your classes immutable before instantiating even a
65    single object.
66
67  Limitations on Inheritance
68    Inheritance isn't easy to implement with arrayrefs. The current
69    implementation suffers from the following limitations:
70
71    *   Single inheritance only.
72
73        You cannot extend multiple parent classes.
74
75    *   Inherit from other MooseX::ArrayRef classes only.
76
77        A MooseX::ArrayRef class cannot extend a non-MooseX::ArrayRef class.
78        Even non-Moose classes which are implemented using arrayrefs. (Of
79        course, all Moose classes inherit from Moose::Object too, which is
80        just fine.)
81
82    Note that delegation (via Moose's `handles`) is often a good alternative
83    to inheritance.
84
85  Issue Tracker
86    Please report any bugs to
87    <http://rt.cpan.org/Dist/Display.html?Queue=MooseX-ArrayRef>.
88
89SEE ALSO
90    Moose, MooseX::GlobRef, MooseX::InsideOut.
91
92AUTHOR
93    Toby Inkster <tobyink@cpan.org>.
94
95COPYRIGHT AND LICENCE
96    This software is copyright (c) 2012 by Toby Inkster.
97
98    This is free software; you can redistribute it and/or modify it under the
99    same terms as the Perl 5 programming language system itself.
100
101DISCLAIMER OF WARRANTIES
102    THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
103    WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
104    MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
105
106