On Mon, Aug 30, 2010 at 3:11 PM, Kiffin Gish <[email protected]> wrote: > I was just wondering. > > What the Moose override command does can pretty much be accomplished by > using Moose MethodModifiers, or so it seems to me. > > Using before, after or around rather than override => sub {} and having > to remember to call super() explicitly seems more elegant to me. > > What then are the advantages/disadvantages of using the one or the > other? > > Thanks alot in advance.
Well, before and after are a little different in practice. They cannot modify the input or return values like around/override can. Semantically there is a difference between modifying a method that could be provided by a Role or a Superclass using around, and only overriding a Superclass method via override. Other than semantics, around receives the "parent" method as it's first parameter while override does not. To call the "parent" method with around you will still need an explicit call to $self->$next(@_) which may or may not be cleaner in your eyes than super(). Finally there are some interactions with Roles and other method modifiers that come into effect as well (method modifiers stack, overrides do not). They really are two different, but similar, creatures. -Chris
