Alter
view release on metacpan or search on metacpan
collection. A class that uses the pure Perl implementation of "Alter"
will obtain this destructor through inheritance (unless "-destroy" is
specified with the "use" statement). So at the surface thread-safety and
garbage-collection are retained. However, if you want to add your own
destructor to a class, you must make sure that both (all) destructors
are called as needed. Perl only calls the first one it meets on the @ISA
tree and that's it.
Otherwise the fallback implementation works like the original. If
compilation has problems, it should allow you to run test cases to help
decide if it's worth trying. To make sure that production code doesn't
inadvertently run with the Perl implementation
Alter::is_xs or die "XS implementation of Alter required";
can be used.
Exports
None by default, "alter()" and "ego()" upon request. Further available
are "STORABLE_freeze", "STORABLE_thaw" and "STORABLE_attach" as well as
"Dumper". ":all" imports all these functions.
Environment
The environment variable "PERL_ALTER_NO_XS" is inspected once at load
time to decide whether to load the XS version of "Alter" or the pure
Perl fallback. At run time it has no effect.
Description
The "Alter" module is meant to facilitate the creation of classes that
support *black-box inheritance*, which is to say that an "Alter" based
class can be a parent class for *any other* class, whether itself
"Alter" based or not. Inside-out classes also have that property.
"Alter" is thus an alternative to the *inside-out* technique of class
construction. In some respects, "Alter" objects are easier to handle.
lib/Alter.pm view on Meta::CPAN
# recognized (and preferred) by Storable 2.15+, (Perl v5.8.8)
# ignored by earlier versions
sub STORABLE_attach {
my ( $class, $cloning, $ser) = @_;
++ our $attaching; # used by t/*.t, not needed for anything else
$class->Alter::reify( Storable::thaw( $ser));
}
# recognized by all versions of Storable
# incidentally, the code is equivalent to STORABLE_attach
sub STORABLE_thaw {
my ( $obj, $cloning, $ser) = @_;
++ our $thawing; # used by t/*.t, not needed for anything else
$obj->Alter::reify( Storable::thaw( $ser));
}
}
1;
__END__
lib/Alter.pm view on Meta::CPAN
for garbage collection. A class that uses the pure Perl implementation
of C<Alter> will obtain this destructor through inheritance (unless
C<-destroy> is specified with the C<use> statement). So at the surface
thread-safety and garbage-collection are retained. However, if
you want to add your own destructor to a class, you must make sure
that both (all) destructors are called as needed. Perl only calls the
first one it meets on the C<@ISA> tree and that's it.
Otherwise the fallback implementation works like the original. If
compilation has problems, it should allow you to run test cases to
help decide if it's worth trying. To make sure that production code
doesn't inadvertently run with the Perl implementation
Alter::is_xs or die "XS implementation of Alter required";
can be used.
=head2 Exports
None by default, C<alter()> and C<ego()> upon request.
Further available are C<STORABLE_freeze>, C<STORABLE_thaw> and
C<STORABLE_attach> as well as C<Dumper>. C<:all> imports all these
functions.
=head2 Environment
The environment variable C<PERL_ALTER_NO_XS> is inspected once at
load time to decide whether to load the XS version of C<Alter> or
the pure Perl fallback. At run time it has no effect.
=head2 Description
The C<Alter> module is meant to facilitate the creation of classes
that support I<black-box inheritance>, which is to say that an
C<Alter> based class can be a parent class for I<any other> class,
whether itself C<Alter> based or not. Inside-out classes also have
that property. C<Alter> is thus an alternative to the I<inside-out>
technique of class construction. In some respects, C<Alter> objects
( run in 1.878 second using v1.01-cache-2.11-cpan-de7293f3b23 )