what's new after 11 months? Changes and additions in the release

Less than a year has passed since the developers waited for a new one stable branch of the Perl programming language – 5.40. Over 160,000 lines of code and 1,500 files were modified in preparation for this release. In total, 75 specialists took part in the work on the release. Well, the details, as always, are under the cut.

What's up with the release?

All new products are released in full accordance with the fixed development schedule approved 11 years ago. According to it, stable branches are released every year, and corrective releases are released every three months. It has now been announced that in a month the first corrective release of Perl 5.40.1 will be released, which will correct the most significant errors identified during the implementation of Perl 5.40.0.

It is worth noting that the developers have stopped supporting branch 5.36. Now updates for it will be released only if critical security problems are discovered. In a few days, the team will begin work on branch 5.41, on the basis of which a stable release of Perl 5.42 will be formed in May or June 2025. By the way, it may well happen that the developers decide to change the release numbering to 7.x.

What's new?

The most important change – extension opportunities, which deal with experimental syntax for creating classes. So, in this release a new word “__CLASS__” appeared, which, when called from methods, ADJUST blocks or when initializing fields, returns the name of the current class, similar to how the __PACKAGE__ keyword returns the name of the package. It can be used to initialize access fields to methods of a class at a stage prior to completing the creation of an instance of the class. Well, for the base class the value of __CLASS__ is identical to the value of __PACKAGE__, but it will differ when creating subclasses.

   use feature 'class';
   class Example1 {
               field $f = __CLASS__->default_f;
               sub default_f { 10 }
   }
  • The :reader attribute has appeared inside the field class, which is used in the case of automatic method creation. It returns the value of a variable from a field in the current instance of the class. So, now specifying an attribute after defining a field means creating a method “method s () { return $s; }”. If necessary, you can specify a non-matching method name using a construct like “field $name :reader(get_name);”.

  • Another important innovation is the declaration of the try/catch exception handling syntax as stable. It can now be used instead of eval. The try block activates the block with the code to be executed, and the catch can handle any exception that might occur while executing the first block. It is also worth noting that in “catch” a variable is defined that contains the data passed when an exception is generated (for example, when an exception is triggered, the string specified as an argument will be passed to the “die” call). Jump statements are allowed inside “try” and “catch” blocks, including return, goto, next, last, and redo.

   try {
               my $x = call_a_function();
               $x < 100 or die "Too big";
               send_output($x);
   }
   catch ($e) {
               warn "Unable to output a value; $e";
   }
   print "Finished\n";
  • The syntax “for my (VAR, VAR) (LIST)” and “foreach my (VAR, VAR) (LIST)” has also become stable. It is used to iterate over lists, retrieving multiple values ​​at once in one iteration of the loop.

  • The builtin module, which includes always available functions built into the interpreter, was also declared stable. Now the module offers such ones as true, false, weaken, unweaken, is_weak, blessed, refaddr, reftype, ceil, floor, is_tainted, trim and indexed.

  • There are also new experimental builtin options inf and nan available in the “builtin::” namespace (“builtin::inf” and “builtin::nan”). These functions can be used as constants that define infinity and non-numeric value.

  • The developers also decided to add a new logical operator “^^”, corresponding to the XOR operation and complementing the bitwise operator “^” (Perl provides three basic bitwise operators “&”, “|” and “^”, corresponding to the AND, OR and XOR operations, but for logical operations the only options available so far have been AND (“&&”) and OR (“||”)). The Boolean expression “$x ^^ $y” will return TRUE when either “x” or “y” is TRUE, but not both.

  • Among the most important changes is the end of support for simulation of versions prior to 5.11. Now using the “use version_number” directive, which disables additional features added to the interpreter after the specified version, will result in an error in the new version.

  • It is allowed to use a space between the command line option “-M” and the module name, for example “perl -M Data::Dumper=Dumper -E 'say Dumper [1,2,3]'” (previously you had to write “perl -MData::Dumper…”).

  • The use of the “goto” operator to move from the outer scope to the inner one has been deprecated. This feature will be discontinued in Perl 5.42.

  • The main structure includes the Term::Table and Test2::Suite modules, designed for creating unit tests. Updated versions of modules Archive::Tar, Compress::Raw::Bzip2, Compress::Raw::Zlib, Data::Dumper, DB_File, File::Compare, File::Find, Getopt::Long, Hash::Util , HTTP::Tiny, IO, Math::BigInt, PerlIO::encoding, Tie::File, Time::HiRes, etc.

  • Added support for the Serenity OS operating system.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *