develooper Front page | perl.moose | Postings from August 2015

Re: 'around' method modifier does not seem to work

Thread Previous | Thread Next
From:
Kent Fredric
Date:
August 8, 2015 02:31
Subject:
Re: 'around' method modifier does not seem to work
Message ID:
CAATnKFAv5Gw9sUU3wsDyLSXmphFAEZMF_inKi60yqwhror7jZQ@mail.gmail.com
On 8 August 2015 at 09:09, Chris Prather <perigrin@prather.org> wrote:
> If you check the part he quoted in the original email, that is in there.
> Obviously three of us missed it so maybe it could be highlighted better.


I think there's confusion stemming from there being *two* methods
being wrapped, one has the guard, and the other has its internals
elided, and we assume there is a guard.

Method one is called "size":

around 'size' => sub {
      my $orig = shift;
      my $self = shift;

      return $self->$orig()   ##### Guard
          unless @_;

      my $size = shift;
      $size = $size / 2
          if $self->likes_small_things();

      return $self->$orig($size);
  };


Method two is called "sequence":

around 'sequence' => sub
{
    my $orig = shift;
    my $self = shift;
    my $sequence = uc shift;

    # Do lots of things with $sequence and then
    #### NO CLEAR GUARD

    return $self->$orig( $sequence );
}



And as he describes, the issue he experiences is predominantly with
the second of these, which makes sense, given there is no code that
*we* can see with the guard mechanism.



-- 
Kent

KENTNL - https://metacpan.org/author/KENTNL

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About