user-pic

ysth

  • Commented on Is there anything wrong with this benchmark?
    I believe Toby is right, and the sub created by around will not recognize any later changes to the inheritance (or redefining of the original sub), which obviously makes it more efficient - as long as you are not making...
  • Commented on What's going on here?
    This is a fine example of why prototypes should not be used on user-created subroutines; just memorizing what they are for the built-ins and expecting the syntactic effects they have is hard enough....
  • Commented on What's going on here?
    While you are correct about how it works, conceptually the issue is simply that an array slice in scalar context produces the last element of the slice. That it actually produces a list and then the last element of the...
Subscribe to feed Recent Actions from ysth

  • Grinnz commented on Is there anything wrong with this benchmark?

    With ->SUPER, your sub is being called first and then it looks up what the superclass is via inheritance. With around, it *creates a new sub* in place and then passes you (at call time) a reference to the previously existing sub, or the method that would have been inherited at the time of 'around'. You're right that later changes to inheritance would not be recognized (changing inheritance at runtime seems like a bad idea in general) but redefining the sub itself would override the 'around' completely since it already installed into that name, so that wouldn't be useful either.

Subscribe to feed Responses to Comments from ysth

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl and offering the modern features you’ve come to expect in blog platforms, the site is hosted by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.