base.pm no longer tracks loaded modules
authorDavid Golden <dagolden@cpan.org>
Thu, 22 Sep 2011 17:33:06 +0000 (13:33 -0400)
committerDavid Golden <dagolden@cpan.org>
Thu, 22 Sep 2011 17:38:06 +0000 (13:38 -0400)
Tracking modules loaded by base.pm to avoid reloading them means
that any module that wishes to force a reload can't just modify
%INC but must also interact with base.pm to clear its cache.

Removing the module-loaded checks have minimal impact.  The internal
call to require() is a NOP for a loaded module.  For an internal
package, the require() will fail with the same error message as
before, which base.pm then ignores.  Tracking modules loaded to avoid
this slight extra overhead is not worth the complexity for other
modules that wish to manipulate %INC.

dist/base/lib/base.pm

index b3443d4..23e7084 100644 (file)
@@ -55,8 +55,6 @@ else {
     }
 }
 
-my %loaded; # track modules loaded via base.pm
-
 sub import {
     my $class = shift;
 
@@ -76,7 +74,8 @@ sub import {
 
         next if grep $_->isa($base), ($inheritor, @bases);
 
-        if (! $loaded{$base}) {
+        # Following blocks help isolate $SIG{__DIE__} changes
+        {
             my $sigdie;
             {
                 local $SIG{__DIE__};
@@ -97,7 +96,6 @@ ERROR
             }
             # Make sure a global $SIG{__DIE__} makes it out of the localization.
             $SIG{__DIE__} = $sigdie if defined $sigdie;
-            $loaded{$base}++;
         }
         push @bases, $base;
 
@@ -212,8 +210,6 @@ the filename does not match the base module name, like so:
 
 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> keeps track of modules that were successfully used as a base and will
-not C<require> them again.
 
 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