Revision history for Perl extension Moose
+0.58
+ * Moose::Exporter
+ * Moose
+ - Moose::Exporter will no longer remove a subroutine that the
+ exporting package re-exports. Moose re-exports the
+ Carp::confess function, among others. The reasoning is that we
+ cannot know whether you have also explicitly imported those
+ functions for your own use, so we err on the safe side and
+ always keep them.
+
0.57 Wed September 3, 2008
* Moose::Intro
- A new bit of doc intended to introduce folks familiar with
my $export_recorder = {};
- my $exports = $class->_make_sub_exporter_params(
+ my ( $exports, $is_removable )
+ = $class->_make_sub_exporter_params(
[ $exporting_package, @exports_from ], $export_recorder );
my $exporter = Sub::Exporter::build_exporter(
\@exports_from, $args{_export_to_main} );
my $unimport = $class->_make_unimport_sub( $exporting_package, $exports,
- $export_recorder );
+ $is_removable, $export_recorder );
return ( $import, $unimport )
}
my $export_recorder = shift;
my %exports;
+ my %is_removable;
for my $package ( @{$packages} ) {
my $args = $EXPORT_SPEC{$package}
$sub,
$export_recorder,
);
+
+ $is_removable{$name} = 1;
}
for my $name ( @{ $args->{as_is} } ) {
if ( ref $name ) {
$sub = $name;
- $name = ( Class::MOP::get_code_info($name) )[1];
+
+ # Even though Moose re-exports things from Carp &
+ # Scalar::Util, we don't want to remove those at
+ # unimport time, because the importing package may
+ # have imported them explicitly ala
+ #
+ # use Carp qw( confess );
+ #
+ # This is a hack. Since we can't know whether they
+ # really want to keep these subs or not, we err on the
+ # safe side and leave them in.
+ my $coderef_pkg;
+ ( $coderef_pkg, $name ) = Class::MOP::get_code_info($name);
+
+ $is_removable{$name} = $coderef_pkg eq $package ? 1 : 0;
}
else {
$sub = do {
no strict 'refs';
\&{ $package . '::' . $name };
};
+
+ $is_removable{$name} = 1;
}
$export_recorder->{$sub} = 1;
}
}
- return \%exports;
+ return ( \%exports, \%is_removable );
}
{
shift;
my $exporting_package = shift;
my $exports = shift;
+ my $is_removable = shift;
my $export_recorder = shift;
return sub {
Moose::Exporter->_remove_keywords(
$caller,
[ keys %{$exports} ],
+ $is_removable,
$export_recorder,
);
};
shift;
my $package = shift;
my $keywords = shift;
+ my $is_removable = shift;
my $recorded_exports = shift;
no strict 'refs';
foreach my $name ( @{ $keywords } ) {
+ next unless $is_removable->{$name};
if ( defined &{ $package . '::' . $name } ) {
my $sub = \&{ $package . '::' . $name };
re-export some other module's functions directly by reference
(C<\&Some::Package::function>).
+If you do export some other packages function, this function will
+never be removed by the C<unimport> method. The reason for this is we
+cannot know if the caller I<also> explicitly imported the sub
+themselves, and therefore wants to keep it.
+
=item * also => $name or \@names
This is a list of modules which contain functions that the caller