Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

5.40 released

by hippo (Archbishop)
on Jun 10, 2024 at 08:35 UTC ( [id://11159868]=perlnews: print w/replies, xml ) Need Help??

Perl 5.40.0 is out now. Grab it while it's hot.


🦛

Replies are listed 'Best First'.
Re: 5.40 released
by marto (Cardinal) on Jun 10, 2024 at 09:06 UTC
Re: 5.40 released
by choroba (Cardinal) on Jun 10, 2024 at 10:01 UTC
    And Syntax::Construct trying to keep up! (Still waiting for Pause to index the latest release... Update: it's up!)
    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re: 5.40 released
by eyepopslikeamosquito (Archbishop) on Jun 11, 2024 at 01:19 UTC

    I just built perl v5.40.0 from source on Ubuntu, using the same steps as last time, without any build problems.

    Note that perl v5.34 added try/catch syntax, inspired by Syntax::Keyword::Try:

    use feature 'try'; try { do_a_thing(); } catch ( $e ) { warn "It failed - $e"; }

    while perl v5.36 further added finally blocks to try/catch, also inspired by Syntax::Keyword::Try:

    use feature 'try'; try { do_a_thing(); } catch( $e ) { ... } finally { cleanup(); }

    While updating my try-catch sample program from perl v5.38.2 to v5.40.0, I noticed that while try-catch feature is no longer experimental with perl v5.40 its use with a finally block still emitted a warning ... presumably because try and catch were added in perl v5.34, while finally was not added until perl v5.36 ... so I expect the finally block warning will finally disappear in perl v5.42. :-)

    👁️🍾👍🦟
Re: 5.40 released
by ikegami (Patriarch) on Jun 13, 2024 at 03:53 UTC
Re: 5.40 released
by cavac (Parson) on Jun 12, 2024 at 14:38 UTC

    I'm one of those old-school people, so i followed ye olde https://cpan.org/src instructions as usual, e.g.

    wget https://www.cpan.org/src/5.0/perl-5.40.0.tar.gz tar -xzf perl-5.40.0.tar.gz cd perl-5.40.0 ./Configure -des -Dprefix=/home/cavac/bin/CavacPerl-5.40.0 make make test make install

    And, as usual, everything works out fine on Xubuntu 22.04 LTS with the latest OS updates(*). And now i can FINALLY write cleaner code:

    #!/usr/bin/env perl use v5.40; use strict; # <-- technically not required, but makes it clear to the +reader we are using strict use warnings; # <-- technically not required (i think), but makes it c +lear to the reader we are using warnings # <- no *EXPERIMENTAL* stuff here for(my $i = 0; $i < 10; $i++) { # Note to reader: Yes, could have used a trinary here, but those a +re hard to read # and therefore forbidden in my codebase print "$i is "; if(!iseven($i)) { print "NOT "; } print "even\n"; } sub iseven($val) { if($val % 2 == 0) { return true; # !!!!! A NATIVE BOOLEAN!!!! } return false; # The *other*, more pessimistic, native boolean ;-) }


    * Famous last words. Still installing all my codebases, but so far everything looks peachy.

        Why would you want it to issue a warning in that context? Seems consistent with
        print $some[ 1 > 0 ], q[ ], $some[ 1 < 0 ];
      for(my $i = 0; $i < 10; $i++) { # Note to reader: Yes, could have used a trinary here, but those a +re hard to read # and therefore forbidden in my codebase print "$i is "; if(!iseven($i)) { print "NOT "; } print "even\n"; }

      The easiest code to read does not have to be read at all because the comments tell you what's happening. If one must write readable Perl then one should use its features instead writing something that looks like C. This is more perlish and way easier to read:

      for (0 .. 9) { print "$_ is "; print "NOT " if not iseven($_); print "even\n"; }

      Code should be optimized for efficient execution more than readability. Here Perl does both, since creating blocks is more expensive than postfix logic, especially inside loops. Peace

        He was simply showing some of the features of the 5.40.0 release, not trying to demonstrate some beautiful or optimized code, making such nitpicking seem pretty out of place and off topic.

        Implicit variables, e.g. $_, are banned from my project. If you use a variable, you have to name it. This makes it much clearer on first glance on what data you are working. And it makes it much easier to move around.

        I should note that i'm paid to develop commercial software, meaning i always have some junior developers come and go. The goal with my code design is to make it easy to convert them from other languages. And i often have to convert code to (or from) Perl to other languages. "The most perlish way" is nearly always a bad idea, whereas a C-like for loop is available in most languages.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-07-16 20:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    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.