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.
  • Installs a stub that delegates to AUTOLOAD. Maybe because there are several of them in the class hierarchy and you want the one in the superclass to take precedence over the one in the subclass, for the methods it implements. Maybe it has to do with making UNIVERSAL::can work correctly.

    • You got it. The promise delegates to AUTOLOAD and AUTOLOAD, of course, can safely overwrite that promise, if needed. This allows can() to behave correctly with various modules which rely on AUTOLOAD to function more-or-less correctly, even if can hasn't been overridden. It also allows you to fulfill a requires for a Moose role.

      One thing it doesn't do is try to replace a reference to itself. That might be annoying if someone does this:

      if ( my $code = $object->can('some_promised_sub') ) {
         

  • but how is this different from

    sub foo;

    (or

    *$fq_name = \&$fq_name;

    if you want to install them dynamically)?

    • You know, I think I'm the one who's being stupid :) As Aristotle points out, my version gives greater dispatch control, but I honestly hadn't thought of that (this reminds me of the time I started writing "tail -f" in Perl before I came to my senses).