davido has asked for the wisdom of the Perl Monks concerning the following question:
"An import list", you say? Who would ever need to pass an import list to an object oriented module?
...except that import lists are sometimes used for other purposes. An example would be use strict 'vars';, where 'vars' is passed to ->import() so that the import routine can alter a specific behavior (not actually import something).
Consider a Moose-based class inheriting from a non-Moose base class. This happens, and often can work out fine. But what if that non-Moose base class needs an import list to configure some feature?
package Foo; use Moose; extends 'MyBase', ['-myfeature']; # An imaginary construct that not su +rprisingly, doesn't work.
extends accepts multiple parent classes, so extends 'MyBase', -myfeature; would blow up. Is there a solution that doesn't involve this?
package Foo; use Moose; use MyBase -myfeature; our @ISA = qw(MyBase);
Dave
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Passing an import list to Moose extends
by LanX (Saint) on May 03, 2018 at 19:41 UTC | |
by davido (Cardinal) on May 03, 2018 at 20:15 UTC | |
by LanX (Saint) on May 03, 2018 at 21:06 UTC | |
Re: Passing an import list to Moose extends
by choroba (Cardinal) on May 03, 2018 at 21:23 UTC | |
Re: Passing an import list to Moose extends
by Anonymous Monk on May 04, 2018 at 13:50 UTC | |
by Veltro (Hermit) on May 04, 2018 at 20:40 UTC | |
by LanX (Saint) on May 04, 2018 at 22:45 UTC | |
by davido (Cardinal) on May 05, 2018 at 05:54 UTC | |
by LanX (Saint) on May 05, 2018 at 12:27 UTC |