Re: changing the default base class
[email protected] (Stevan Little)
| Newsgroups | perl.moose |
|---|---|
| Message-ID | <[email protected]> |
Base Classes Bad, Roles Good :)
http://en.wikipedia.org/wiki/Fragile_base_class
On Nov 17, 2006, at 11:40 AM, Todd Hepler wrote:
> Jonathan Swartz wrote:
> >
> > package My::Person;
> > use My::Moose; # automatically sets superclass to
> > My::Moose::Object, instead of Moose::Object
>
> I have wanted something similar, and ended up with this:
>
> package My::Moose;
> sub import {
> my $caller = caller();
> eval qq{
> package $caller;
> use Moose;
> extends 'My::Moose::Object';
> };
> die $@ if $@;
> }
>
> Though, there's gotta be a better way...
>
> Stevan Little wrote:
>> Jonathan,
>> On Nov 17, 2006, at 7:45 AM, Jonathan Swartz wrote:
>>> Or perhaps I could use Moose::Policy for this. But then each
>>> class would read
>>>
>>> package My::Person;
>>> use Moose::Policy 'My::Moose::Policy';
>>> use Moose;
>> Yes, this would be the way to go about it (kind of).
>>> Yuck. It seems like a significant blow to the syntactic single-
>>> use-line beauty of Moose, and a violation of DRY.
>> I agree it is uglier, however, I don't see it as a violation of DRY.
>
> It might be nice if you could leave out the "use Moose". I think
> that's the repetition.
>
> -Todd
>