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

Re^8: If Perl 5 were to become Perl 7, what (backward-compatible) features would you want to see?

by holli (Abbot)
on Oct 22, 2019 at 10:21 UTC ( [id://11107841]=note: print w/replies, xml ) Need Help??


in reply to Re^7: If Perl 5 were to become Perl 7, what (backward-compatible) features would you want to see?
in thread If Perl 5 were to become Perl 7, what (backward-compatible) features would you want to see?

Neat. Neater, see below. ;-)

*** Trigger Warning *** Raku content *** Trigger Warning ***
use DBIish; role DB-Connection { has $.dbh; submethod TWEAK( :$dbh! ) { $!dbh = $dbh.isa(DBIish) ?? $dbh !! DBIish.connect( |%$dbh + ); } }
Notes: The ! after $dbh, in the signature of the TWEAK method makes $dbh argument required. The colon indicates it is a named argument, rather than a positional one.
Attributes are always read only by default.
The |%$dbh does two things. The % "dereferences" (rather re-containerizes) the Hash in $dbh. The | then flattens that hash into named subroutine arguments.


holli

You can lead your users to water, but alas, you cannot drown them.
  • Comment on Re^8: If Perl 5 were to become Perl 7, what (backward-compatible) features would you want to see?
  • Select or Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-24 02:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found