summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/base.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlperl/lib/base.pm')
-rw-r--r--Master/tlpkg/tlperl/lib/base.pm42
1 files changed, 14 insertions, 28 deletions
diff --git a/Master/tlpkg/tlperl/lib/base.pm b/Master/tlpkg/tlperl/lib/base.pm
index 8c60b614fab..19fc8456d23 100644
--- a/Master/tlpkg/tlperl/lib/base.pm
+++ b/Master/tlpkg/tlperl/lib/base.pm
@@ -2,7 +2,7 @@ package base;
use strict 'vars';
use vars qw($VERSION);
-$VERSION = '2.16';
+$VERSION = '2.18';
$VERSION = eval $VERSION;
# constant.pm is slow
@@ -22,12 +22,6 @@ sub has_fields {
return( ($fglob && 'GLOB' eq ref($fglob) && *$fglob{HASH}) ? 1 : 0 );
}
-sub has_version {
- my($base) = shift;
- my $vglob = ${$base.'::'}{VERSION};
- return( ($vglob && *$vglob{SCALAR}) ? 1 : 0 );
-}
-
sub has_attr {
my($proto) = shift;
my($class) = ref $proto || $proto;
@@ -70,7 +64,6 @@ sub import {
my $fields_base;
my $inheritor = caller(0);
- my @isa_classes;
my @bases;
foreach my $base (@_) {
@@ -80,11 +73,8 @@ sub import {
next if grep $_->isa($base), ($inheritor, @bases);
- if (has_version($base)) {
- ${$base.'::VERSION'} = '-1, set by base.pm'
- unless defined ${$base.'::VERSION'};
- }
- else {
+ # Following blocks help isolate $SIG{__DIE__} changes
+ {
my $sigdie;
{
local $SIG{__DIE__};
@@ -105,8 +95,6 @@ ERROR
}
# 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 @bases, $base;
@@ -121,8 +109,6 @@ ERROR
}
}
# 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 ) {
@@ -206,26 +192,26 @@ those modules at the same time. Roughly similar in effect to
push @ISA, qw(Foo Bar);
}
-C<base> employs some heuristics to determine if a module has already been
-loaded, if it has it doesn't try again. If C<base> tries to C<require> the
-module it will not die if it cannot find the module's file, but will die on any
-other error. After all this, should your base class be empty, containing no
-symbols, it will die. This is useful for inheriting from classes in the same
-file as yourself, like so:
+When C<base> tries to C<require> a module, it will not die if it cannot find
+the module's file, but will die on any other error. After all this, should
+your base class be empty, containing no symbols, C<base> will die. This is
+useful for inheriting from classes in the same file as yourself but where
+the filename does not match the base module name, like so:
+ # in Bar.pm
package Foo;
sub exclaim { "I can have such a thing?!" }
-
+
package Bar;
use base "Foo";
-If $VERSION is not detected even after loading it, <base> will define $VERSION
-in the base package, setting it to the string C<-1, set by base.pm>.
+There is no F<Foo.pm>, but because C<Foo> defines a symbol (the C<exclaim>
+subroutine), C<base> will not die when the C<require> fails to load F<Foo.pm>.
C<base> will also initialize the fields if one of the base classes has it.
Multiple inheritance of fields is B<NOT> supported, if two or more base classes
-each have inheritable fields the 'base' pragma will croak. See L<fields>,
-L<public> and L<protected> for a description of this feature.
+each have inheritable fields the 'base' pragma will croak. See L<fields>
+for a description of this feature.
The base class' C<import> method is B<not> called.