Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Refactoring example (A good one? (Perl6))

by holli (Abbot)
on Aug 13, 2019 at 11:11 UTC ( [id://11104377]=note: print w/replies, xml ) Need Help??


in reply to Re: Refactoring example (A good one? (Perl6))
in thread Refactoring example (A good one? (Perl6))

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.

Replies are listed 'Best First'.
Re^3: Refactoring example (A good one? (Perl6))
by jcb (Parson) on Aug 14, 2019 at 02:54 UTC
    Maybe available-plugins should be export on demand.

    Would it be possible to make the new functionality a plugin to Pluggable itself? Maybe Pluggable::Enumerable?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11104377]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (1)
As of 2024-04-16 21:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found