Perl 5.36.0 programming language available

After a year of development, the release of a new stable branch of the Perl programming language, 5.36, has been published. When preparing the new release, about 250 thousand lines of code were changed, the changes affected 2000 files, 82 developers took part in the development.

Branch 5.36 is released in accordance with the fixed development schedule approved nine years ago, which implies the release of new stable branches once a year and corrective releases every three months. The first corrective release of Perl 5.36.1 is scheduled to be released in about a month, fixing the most significant bugs identified during the implementation of Perl 5.36.0. Along with the release of Perl 5.36, support for the 5.32 branch was dropped, which can only be updated in the future if critical security issues are identified. The development process for the 5.37 experimental branch has also begun, from which the stable release of Perl 2023 will form in May or June 5.38, unless a decision is made to move to 7.x numbering.

Key changes:

  • Support for function signatures has been stabilized and is now available when specifying the "use v5.36" pragma, which allows you to explicitly define the list of variables used in the function and automate the operations of checking and assigning values ​​from the array of input parameters. For example, the previously used code: sub foo { die "Too many arguments for subroutine" unless @_ >= 2; die "Too few arguments for subroutine" unless @_ <= 2; my($left, $right) = @_; return $left + $right; }

    when using signatures, it can be replaced by:

    sub foo ($left, $right) { return $left + $right; }

    Calling foo with more than two arguments will cause the interpreter to throw an error. The list also supports a special variable "$", which allows you to ignore some of the arguments, for example, "sub foo ($left, $, $right)" will allow you to copy only the first and third arguments to the variables, while exactly three argument.

    The signature syntax also allows you to specify optional arguments and set default values ​​if an argument is missing. For example, by specifying "sub foo ($left, $right = 0)", the second argument becomes optional and, if it is absent, the value 0 is passed. An arbitrary expression can be specified in the assignment operation, including using other variables from the list or global variables. Specifying a hash or array instead of a variable (for example, "sub foo ($left, @right)") will result in the possibility of passing one or more arguments.

  • In functions declared using signatures, support for additional assignment of parameters from the "@_" array is declared experimental and will result in a warning (a warning is only issued if @_ is used in functions declared using the new syntax). For example, a warning will be issued for the function: use v5.36; sub f ($x, $y = 123) { say "The first argument is $_[0]"; }
  • Stabilized and available when specifying the "use v5.36" pragma, the "isa" infix operator for checking whether an object is an instance of the specified class or a class derived from it. For example: if( $obj isa Package::Name ) { … }
  • When specifying the "use v5.36" pragma, the processing of warnings is enabled (the "use warnings" mode is activated).
  • When specifying the "use v5.36" pragma, support for indirect notation of calling objects ("feature indirect") is disabled - an obsolete way of calling objects, in which a space is used instead of "->" ("method $object @param" instead of "$object-> $method(@param)"). For example, instead of "my $cgi = new CGI" you would use "my $cgi = CGI->new".
  • When specifying the "use v5.36" pragma, support for emulating multidimensional arrays and Perl 4-style hashes ("feature multidimensional") was disabled, allowing multiple keys to be translated into an intermediate array (for example, "$hash{1, 2}") was converted to "$hash{join($;, 1, 2)}").
  • The "use v5.36" pragma disables support for an experimental branching mechanism ("feature switch") similar to switch and case statements (Perl uses the given and when keywords). Since Perl 5.36, you must explicitly specify 'use feature "switch"' to use this feature, and specifying "use version" will no longer automatically enable it.
  • Stabilized and available by default support for additional character classes in square brackets inside regular expressions. The capability allows for matching using extended rules for intersecting, excluding, and concatenating multiple characters. For example, '[AZ - W]' is the characters from A to Z excluding W.
  • Support for the operations “(?”, “( )”, “{ }” and “[ ]” is partially stabilized and available by default. You can use the characters ““ ””, ““ ””, etc. "".
  • It is forbidden to call the sort function without arguments, which will now lead to an error output. @a = sort @empty; # continue @a = sort; # will throw an error @a = sort (); # an error will be thrown
  • A new command line flag "-g" has been proposed, which enables the mode of downloading the entire file, rather than line by line. The flag has the same effect as "-0777".
  • Support for the Unicode specification has been updated to version 14.0.
  • Instant floating point exception (SIGFPE) handling similar to other alarms such as SIGSEGV is provided, allowing custom handlers to be attached to the SIGFPE signal via $SIG{FPE}, for example outputting the line number where the problem occurred.
  • Updated versions of modules included in the basic distribution.
  • Added performance optimizations. The ability to store large hash keys more efficiently, without the use of shared string tables, is provided. The performance of creating new scalar values ​​has been significantly improved, for example, the following code now runs 30% faster: $str = "A" x 64; for (0..1_000_000) { @svs = split //, $str }
  • The interpreter code began to use some of the constructs defined in the C99 standard. Building Perl now requires a compiler that supports C99. Assembly support has been dropped in older versions of MSVC++ (before VC12). Added assembly support in Microsoft Visual Studio 2022 (MSVC++ 14.3).
  • Support for AT&T UWIN, DOS/DJGPP, and Novell NetWare platforms has been dropped.

Source: opennet.ru

Add a comment