Interesting. But they are quite wrong (see above). They start out with a factual truth: passing in by @_ is fastest. (I wonder if passing in a single array ref would be faster ... one way to find out!) However, they then go and explain how they'll use this "fast" method to go and make it readable and extendable. Well, guess what. It's not.

Rather than starting out with the fastest method and making it more readable, they should have evaluated all methods, and picked the most readable and fast method. They discarded all alternatives over a perceived speed difference, and then used up way more than that speed difference in making it readable. Kudos for making it readable and forward-thinking. A pox for thinking inside an artificial box.

Update: Yes, a major typo in the code screwed this up. Ok, so it's not significantly slower. I still think it's unreadable :-)

#! /usr/bin/perl use Benchmark qw(cmpthese); use constant {OBJECT => 0, KERNEL => 1, HEAP => 2, SESSION => 3, }; cmpthese( 0, { POE => sub { poe_style(qw(a b c d)); }, Normal => sub { regular_style(qw(a b c d)); }, Ref_Copy => sub { reg_ref('a', [qw(b c d)]); }, Ref_Named => sub { ref_named('a', { kernel => 'b', heap => 'c', session => 'd', } ); }, Named => sub { named_style('a', kernel => 'b', heap => 'c', session => 'd', ); }, Shift => sub { shift_style(qw(a b c d)); }, } ); sub poe_style { my ($self, $kernel, $heap, $session) = @_[ OBJECT, KERNEL, HEAP, S +ESSION ]; 0; } sub regular_style { my $self = shift; my ($kernel, $heap, $session) = @_; 0; } sub reg_ref { my $self = shift; my ($kernel, $heap, $session) = @$_[0]; 0; } sub named_style { my $self = shift; my %opts = @_; 0; } sub ref_named { my $self = shift; my $opts = $_[0]; 0; } sub shift_style { my $self = shift; my $kernel = shift; my $heap = shift; my $session = shift; 0; }

Short version: The calling types they said would be slower than "normal" are. But they're all faster than the one they ended up with. The unintuitiveness of this style still causes problems. As in calling SUPER.


In reply to Re^5: POE OO sessions - accessing overwritten methods by Tanktalus
in thread POE OO sessions - accessing overwritten methods by m-rau

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.