I will admit that learning Perl 6 has just found its way onto my TODO list ... somewhere. That is a very interesting language.
You ain't seen nothing yet ;-)
Back on topic, is Pluggable a mixin? Would this refactoring change the interface exposed by other classes that use Pluggable? Could the original "narrow" interface have been a goal in itself?
It's a Role, yes. I think you got kind of a point there. Maybe available-plugins should be export on demand.
The original version fits on a single screen here if I stretch my edit window, while the refactored version crosses that threshold into requiring scrolling. For that reason alone, I expect that the original would be easier for me to debug, although the exact threshold here is a quirk of my environment and YMMV. I am also assuming, based on the reputation of St. Larry, that the Perl 6 debugger is at least as capable as the Perl 5 debugger when inspecting the function of seemingly monolithic blocks of code.
Keep in mind my version has addditional functionality. If I were to add that in the style of the original, the result would be two to three times as long and include several repetitions.
I do not know enough about Perl 6 to be sure, but the refactored version "feels like" it may do more work than the original. This may just be a cognitive bias because it is longer, and the actual code paths may be more efficient or at least equivalent if the new functionality is not used, but it "feels" questionable to me.
You're a programmer, not a millenial jedi.
I do not know if Perl 6 can inline my sub or not, but I know that calling a sub is not free in Perl 5 (among the best as far as interpreted languages go, but not free) as I learned using HTML::Parser on long and complex documents.
In Perl 6 everything is an object, even Subs. And operators are just a special kind of Sub, which is why it is so easy to define new or overload existing operators. Therefore the runtime optimizer goes through great lengths to inline things and/or to avoid stack operations where possible. That's part of the reason why subroutine arguments are by default read only.


holli

You can lead your users to water, but alas, you cannot drown them.

In reply to Re^2: Refactoring example (A good one? (Perl6)) by holli
in thread Refactoring example (A good one? (Perl6)) by holli

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.