Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re^2: Moose - two augmented methods in one class

by zwon (Abbot)
on Jan 09, 2012 at 15:25 UTC ( #947021=note: print w/replies, xml ) Need Help??

in reply to Re: Moose - two augmented methods in one class
in thread Moose - two augmented methods in one class

Update: ignore this, tobyink is right, I didn't pay enough attention to the question

This cumbersome check is not really required. inner is no-op if there's no augment:

use 5.010; use strict; use warnings; { package C1; use Moose; sub test { return "<C1>".(inner()//'')."</C1>"; } } { package C2; use Moose; extends 'C1'; } my $c2 = C2->new; say $c2->test; __END__ <C1></C1>

Replies are listed 'Best First'.
Re^3: Moose - two augmented methods in one class
by tobyink (Abbot) on Jan 09, 2012 at 15:37 UTC

    Actually, in the example, it does seem necessary, as it seems to hit onto a barely documented area of Moose behaviour bug according to several people in #moose in The html method defined in the superclass, calls head defined in the invocant. head isn't augmented in the subclass, so the head method defined in the superclass is used directly. This calls inner which searches up the callstack for an augmented method. While we'd want it to find head, that method is not augmented in the subclass, so it finds html instead, inadvertently using the wrong augmentation.

    Try the code from the original question and you'll see.

        I think the lesson to be learned here is simply "don't use augment/inner for anything complicated", which can be whittled down to "don't use augment/inner" if you like.

        Basically, it was an interesting feature, but not something I would advise leaning on too heavily. Not only is the implementation problematic, but the semantics are just plain weird (even in the BETA language from which I originally stole it).


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://947021]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2018-06-17 23:09 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (107 votes). Check out past polls.