Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: lexical sub vs subroutine reference

by haj (Vicar)
on Jul 26, 2024 at 19:37 UTC ( [id://11160780]=note: print w/replies, xml ) Need Help??


in reply to Re^2: lexical sub vs subroutine reference
in thread lexical sub vs subroutine reference

That article uses strong words like "almost irredeemably broken", "incredibly bad idea", which I consider outright wrong.

The issues with our sub speak { ... } are rather obvious. Technically our makes "lexical" aliases, but I have never seen a use case to use our together with sub.

A different thing is my sub speak { ... }. This is what I would call a named lexical subroutine, and I use them occasionally. They work for sort since 5.22, which was released nine years ago, so shortly after brian d foy wrote his rant. And they are no longer experimental, they just work.

While it is correct that you can achieve the same goals with a code reference to an anonymous subroutine, I prefer my sub. It looks "nicer" to me, and I am not distracted by looking whether the code reference is passed to other routines in other packages.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-09-18 14:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (25 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.