1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
package List::Objects::WithUtils::Array::Immutable;
$List::Objects::WithUtils::Array::Immutable::VERSION = '2.028003';
use strictures 2;
require Role::Tiny;
Role::Tiny->apply_roles_to_package( __PACKAGE__,
qw/
List::Objects::WithUtils::Role::Array
List::Objects::WithUtils::Role::Array::WithJunctions
List::Objects::WithUtils::Role::Array::Immutable
/,
);
use Exporter ();
our @EXPORT = 'immarray';
sub import {
my $pkg = caller;
{ no strict 'refs';
${"${pkg}::a"} = ${"${pkg}::a"};
${"${pkg}::b"} = ${"${pkg}::b"};
}
goto &Exporter::import
}
sub immarray { __PACKAGE__->new(@_) }
1;
=pod
=head1 NAME
List::Objects::WithUtils::Array::Immutable - Immutable array objects
=head1 SYNOPSIS
use List::Objects::WithUtils 'immarray';
my $array = immarray(qw/ a b c /);
my ($head, $rest) = $array->head;
=head1 DESCRIPTION
These are immutable array objects; attempting to call list-mutating methods
(or modify the backing array directly) will throw an exception.
This class consumes the following roles, which contain most of the relevant
documentation:
L<List::Objects::WithUtils::Role::Array>
L<List::Objects::WithUtils::Role::Array::WithJunctions>
L<List::Objects::WithUtils::Role::Array::Immutable>
(See L<List::Objects::WithUtils::Array> for a mutable implementation.)
=head2 immarray
Creates a new immutable array object.
=head1 AUTHOR
Jon Portnoy <avenj@cobaltirc.org>
Licensed under the same terms as Perl.
=cut
|