in reply to Re: SUPER or NEXT from imported methods
in thread SUPER or NEXT from imported methods

Thanks for maintaining this module on CPAN and for noting its usefulness here.

I think the module's documentation (SUPER) could be made a lot clearer. For example, your reply appears to contradict the module documentation (original emphasis included):

Note: you must have the appropriate package declaration in place for this to work. That is, you must have compiled the method in which you use this function in the package from which you want to use it. Them's the breaks with Perl 5.

But perhaps that caveat doesn't apply to one or more other features of the module? That kinda makes sense since this caveat appears under the documentation for the super function (the super method appears in sample code but otherwise doesn't appear to be documented?). But that interpretation is rather at odds with "Them's the breaks with Perl 5." So I'm not completely sure how I'm supposed to interpret that.

As another example, the phrase "Call it directly." is much less clear than including actual code that demonstrates the proper way to call something.

I'd also more clearly mark sample code that is not demonstrating how to use the module. For example, include a comment in such sample code:

# Without this module you'd write: $self->SUPER::method(@_);

since the sentence(s) above the code block are so much less prominent to the eye.

I'm also unsure how SUPER() becomes a method of my class. There is no documentation of how one invokes the module itself (I can tell that 'use' is required but it would be nice to state that and even give better hints about what arguments can be passed in when the module is used). I'm guessing that I'm not supposed to inherit from the module.

I assume that "all parents" means "the names of all (immediate?) parent classes" but that just leaves me wondering why $class is passed into it (rather than it just using ref($invocant) -- or is that supposed to be the current class that should be skipped, ie. what __PACKAGE__ would be if you didn't need this module?). There are several hints that "immediate" applies (indeed, "parent" is not "ancestor"). And I'd prefer to see the order used to search the hierarchy spelled out.

I suspect most of this would become clear to me if I just gave in and read the source code, but it would probably be better for this to not be a requirement for understanding the module.

Thanks, again.

- tye        

Replies are listed 'Best First'.
Re^3: SUPER or NEXT from imported methods (SUPER.pm)
by tilly (Archbishop) on Feb 21, 2009 at 08:45 UTC
    From skimming the module documentation it looks like you should be able to do this:
    $some_package->super("some_method")->($obj, @arguments);
    which would fill in all of the "walk the symbol table" bits in the second option that I gave you for how to solve this.

    I wouldn't have noticed that if I hadn't read carefully with the expectation that chromatic was almost certainly right that it could indeed solve your problem.