Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Why would I use your module instead of the namespace module? It seems like your module solves a sub-set of the problem solved by the namespace module. I read your docs but they didn't seem to answer the question. Maybe I missed something...

    -sam

    • First, if you just want the last part of the class name, aliased has the simpler syntax:

      use aliased "Really::Long::Class::Name::For::Customer";
      my $cust = Customer->new;

      # versus

      use namespace Customer => "Really::Long::Class::Name::For::Customer";
      my $cust = Customer->new;

      Second, compare the implementations. I am just exporting a single subroutine. namespace jumps through a lot of weird hoops, diddles the aliased @ISA array, and has rather coplicated code. Further, it will die if the target n

      • Yes, I think you should document it, particularly since you mention a good reason that I would use namespace: it works for :: in addition to ->. I find the point about tests to be particularly compelling, personally.

        -sam

        • I was mistaken. namespace also does not allow function calls. In trying this with my test suite, I have this:

          #!/usr/local/bin/perl
          use warnings;
          use strict;
          use lib 't/lib';

          use namespace 'This::Name' => 'Really::Long::Module::Name';

          use Data::Dumper;
          print Dumper( This::Name::new('This::Name') );

          It says that This::Name::new is an undefined subroutine. But, it turns out the problem is worse than that!

          #!/usr/local/bin/perl
          use warnings;
          use strict;
          use lib 't/lib';

          use namespace 'This::Name' => 'Real