use strict 'vars';
use vars qw($VERSION);
-$VERSION = '2.12';
+$VERSION = '2.14';
+$VERSION = eval $VERSION;
# constant.pm is slow
sub SUCCESS () { 1 }
my $fields_base;
my $inheritor = caller(0);
+ my @isa_classes;
+ my @bases;
foreach my $base (@_) {
if ( $inheritor eq $base ) {
warn "Class '$inheritor' tried to inherit from itself\n";
}
- next if $inheritor->isa($base);
+ next if grep $_->isa($base), ($inheritor, @bases);
if (has_version($base)) {
${$base.'::VERSION'} = '-1, set by base.pm'
die if $@ && $@ !~ /^Can't locate .*? at \(eval /;
unless (%{"$base\::"}) {
require Carp;
+ local $" = " ";
Carp::croak(<<ERROR);
Base class package "$base" is empty.
- (Perhaps you need to 'use' the module which defines that package first.)
+ (Perhaps you need to 'use' the module which defines that package first,
+ or make that module available in \@INC (\@INC contains: @INC).
ERROR
}
- $sigdie = $SIG{__DIE__};
+ $sigdie = $SIG{__DIE__} || undef;
}
# Make sure a global $SIG{__DIE__} makes it out of the localization.
$SIG{__DIE__} = $sigdie if defined $sigdie;
${$base.'::VERSION'} = "-1, set by base.pm"
unless defined ${$base.'::VERSION'};
}
- push @{"$inheritor\::ISA"}, $base;
+ push @bases, $base;
if ( has_fields($base) || has_attr($base) ) {
# No multiple fields inheritance *suck*
}
}
}
+ # Save this until the end so it's all or nothing if the above loop croaks.
+ push @{"$inheritor\::ISA"}, @isa_classes;
+
+ push @{"$inheritor\::ISA"}, @bases;
if( defined $fields_base ) {
inherit_fields($inheritor, $fields_base);
=head1 DESCRIPTION
+Unless you are using the C<fields> pragma, consider this module discouraged
+in favor of the lighter-weight C<parent>.
+
Allows you to both load one or more modules, while setting up inheritance from
those modules at the same time. Roughly similar in effect to