![]() |
![]()
| ![]() |
![]()
NAMEperl5360delta - what is new for perl v5.36.0 DESCRIPTIONThis document describes differences between the 5.34.0 release and the 5.36.0 release. Core Enhancements"use v5.36"As always, "use v5.36" turns on the feature bundle for that version of Perl. The 5.36 bundle enables the "signatures" feature. Introduced in Perl version 5.20.0, and modified several times since, the subroutine signatures feature is now no longer considered experimental. It is now considered a stable language feature and no longer prints a warning. use v5.36; sub add ($x, $y) { return $x + $y; } Despite this, certain elements of signatured subroutines remain experimental; see below. The 5.36 bundle enables the "isa" feature. Introduced in Perl version 5.32.0, this operator has remained unchanged since then. The operator is now considered a stable language feature. For more detail see "Class Instance Operator" in perlop. The 5.36 bundle also disables the features "indirect", and "multidimensional". These will forbid, respectively: the use of "indirect" method calls (like "$x = new Class;"); the use of a list expression as a hash key to simulate sparse multidimensional arrays. The specifics of these changes can be found in feature, but the short version is: this is a bit like having more "use strict" turned on, disabling features that cause more trouble than they're worth. Furthermore, "use v5.36" will also enable warnings as if you'd written "use warnings". Finally, with this release, the experimental "switch" feature, present in every feature bundle since they were introduced in v5.10, has been removed from the v5.36 bundle. If you want to use it (against our advice), you'll have to enable it explicitly. -g command-line flagA new command-line flag, -g, is available. It is a simpler alias for -0777. For more information, see "-g" in perlrun. Unicode 14.0 is supportedSee <https://www.unicode.org/versions/Unicode14.0.0/> for details. regex sets are no longer considered experimentalPrior to this release, the regex sets feature (officially named "Extended Bracketed Character Classes") was considered experimental. Introduced in Perl version 5.18.0, and modified several times since, this is now considered a stable language feature and its use no longer prints a warning. See "Extended Bracketed Character Classes" in perlrecharclass. Variable length lookbehind is mostly no longer considered experimentalPrior to this release, any form of variable length lookbehind was considered experimental. With this release the experimental status has been reduced to cover only lookbehind that contains capturing parenthesis. This is because it is not clear if "aaz"=~/(?=z)(?<=(a|aa))/ should match and leave $1 equaling "a" or "aa". Currently it will match the longest possible alternative, "aa". While we are confident that the overall construct will now match only when it should, we are not confident that we will keep the current "longest match" behavior. SIGFPE no longer deferredFloating-point exceptions are now delivered immediately, in the same way as other "fault"-like signals such as SIGSEGV. This means one has at least a chance to catch such a signal with a $SIG{FPE} handler, e.g. so that "die" can report the line in perl that triggered it. Stable boolean trackingThe "true" and "false" boolean values, often accessed by constructions like "!!0" and "!!1", as well as being returned from many core functions and operators, now remember their boolean nature even through assignment into variables. The new function is_bool() in builtin can check whether a value has boolean nature. This is likely to be useful when interoperating with other languages or data-type serialisation, among other places. iterating over multiple values at a time (experimental)You can now iterate over multiple values at a time by specifying a list of lexicals within parentheses. For example, for my ($key, $value) (%hash) { ... } for my ($left, $right, $gripping) (@moties) { ... } Prior to perl v5.36, attempting to specify a list after "for my" was a syntax error. This feature is currently experimental and will cause a warning of category "experimental::for_list". For more detail see "Compound Statements" in perlsyn. See also "builtin::indexed" in this document, which is a handy companion to n-at-a-time foreach. builtin functions (experimental)A new core module builtin has been added, which provides documentation for new always-present functions that are built into the interpreter. say "Reference type of arrays is ", builtin::reftype([]); It also provides a lexical import mechanism for providing short name versions of these functions. use builtin 'reftype'; say "Reference type of arrays is ", reftype([]); This builtin function mechanism and the functions it provides are all currently experimental. We expect that "builtin" itself will cease to be experimental in the near future, but that individual functions in it may become stable on an ongoing basis. Other functions will be added to "builtin" over time. For details, see builtin, but here's a summary of builtin functions in v5.36:
"defer" blocks (experimental)This release adds support for "defer" blocks, which are blocks of code prefixed by the "defer" modifier. They provide a section of code which runs at a later time, during scope exit. In brief, when a "defer" block is reached at runtime, its body is set aside to be run when the enclosing scope is exited. It is unlike a UNITCHECK (among other reasons) in that if the block containing the "defer" block is exited before the block is reached, it will not be run. "defer" blocks can be used to take the place of "scope guard" objects where an object is passed a code block to be run by its destructor. For more information, see "defer blocks" in perlsyn. try/catch can now have a "finally" block (experimental)The experimental "try"/"catch" syntax has been extended to support an optional third block introduced by the "finally" keyword. try { attempt(); print "Success\n"; } catch ($e) { print "Failure\n"; } finally { print "This happens regardless\n"; } This provides code which runs at the end of the "try"/"catch" construct, even if aborted by an exception or control-flow keyword. They are similar to "defer" blocks. For more information, see "Try Catch Exception Handling" in perlsyn. non-ASCII delimiters for quote-like operators (experimental)Perl traditionally has allowed just four pairs of string/pattern delimiters: "( )" "{ }" "[ ]" and "< >", all in the ASCII range. Unicode has hundreds more possibilities, and using this feature enables many of them. When enabled, you can say "qr« »" for example, or "use utf8; q𝄃string𝄂". See "The 'extra_paired_delimiters' feature" in feature for details. @_ is now experimental within signatured subsEven though subroutine signatures are now stable, use of the legacy arguments array (@_) with a subroutine that has a signature remains experimental, with its own warning category. Silencing the "experimental::signatures" warning category is not sufficient to dismiss this. The new warning is emitted with the category name "experimental::args_array_with_signatures". Any subroutine that has a signature and tries to make use of the defaults argument array or an element thereof (@_ or $_[INDEX]), either explicitly or implicitly (such as "shift" or "pop" with no argument) will provoke a warning at compile-time: use v5.36; sub f ($x, $y = 123) { say "The first argument is $_[0]"; } Use of @_ in array element with signatured subroutine is experimental at file.pl line 4. The behaviour of code which attempts to do this is no longer specified, and may be subject to change in a future version. Incompatible ChangesA physically empty sort is now a compile-time error@a = sort @empty; # unaffected @a = sort; # now a compile-time error @a = sort (); # also a compile-time error A bare sort used to be a weird way to create an empty list; now it croaks at compile time. This change is intended to free up some of the syntax space for possible future enhancements to "sort". Deprecations"use VERSION" (where VERSION is below v5.11) after "use v5.11" is deprecatedWhen in the scope of "use v5.11" or later, a "use vX" line where X is lower than v5.11 will now issue a warning: Downgrading a use VERSION declaration to below v5.11 is deprecated For example: use v5.14; say "The say statement is permitted"; use v5.8; # This will print a warning print "We must use print\n"; This is because the Perl team plans to change the behavior in this case. Since Perl v5.12 (and parts of v5.11), strict is enabled unless it had previously been disabled. In other words: no strict; use v5.12; # will not enable strict, because "no strict" preceded it $x = 1; # permitted, despite no "my" declaration In the future, this behavior will be eliminated and "use VERSION" will always enable strict for versions v5.12 and later. Code which wishes to mix versions in this manner should use lexical scoping with block syntax to ensure that the differently versioned regions remain lexically isolated. { use v5.14; say "The say statement is permitted"; } { use v5.8; # No warning is emitted print "We must use print\n"; } Of course, this is probably not something you ever need to do! If the first block compiles, it means you're using perl v5.14.0 or later. Performance Enhancements
The shared string table was originally added to improve performance for blessed hashes used as objects, because every object instance has the same keys, so it is an optimisation to share memory between them. It also makes sense for symbol tables, where derived classes will have the same keys (typically method names), and the OP trees built for method calls can also share memory. The shared string table behaves roughly like a cache for hash keys. But for hashes actually used as associative arrays - mapping keys to values - typically the keys are not re-used in other hashes. For example, "seen" hashes are keyed by object IDs (or addresses), and logically these keys won't repeat in other hashes. Storing these "used just once" keys in the shared string table increases CPU and RAM use for no gain. For such keys the shared string table behaves as a cache with a 0% hit rate. Storing all the keys there increases the total size of the shared string table, as well as increasing the number of times it is resized as it grows. Worse - in any environment that has "copy on write" memory for child process (such as a pre-forking server), the memory pages used for the shared string table rapidly need to be copied as the child process manipulates hashes. Hence if most of the shared string table is such that keys are used only in one place, there is no benefit from re-use within the perl interpreter, but a high cost due to more pages for the OS to copy. The perl interpreter can now be Configured to disable shared hash keys for "large" hashes (that are neither objects nor symbol tables). To do so, add "-Accflags='-DPERL_USE_UNSHARED_KEYS_IN_LARGE_HASHES'" to your Configure options. "Large" is a heuristic -- currently the heuristic is that sharing is disabled when adding a key to a hash triggers allocation of more storage, and the hash has more than 42 keys. This might cause slightly increased memory usage for programs that create (unblessed) data structures that contain multiple large hashes that share the same keys. But generally our testing suggests that for the specific cases described it is a win, and other code is unaffected.
Modules and PragmataUpdated Modules and Pragmata
DocumentationNew DocumentationPorting/vote_admin_guide.pod This document provides the process for administering an election or vote within the Perl Core Team. Changes to Existing DocumentationWe have attempted to update the documentation to reflect the changes listed in this document. If you find any we have missed, open an issue at <https://github.com/Perl/perl5/issues>. Additionally, the following selected changes have been made: perlapi
perldeprecation
perlexperiment
perlgov
perlop
perlre
perlrun
DiagnosticsThe following additions or changes have been made to diagnostic output, including warnings and fatal error messages. For the complete list of diagnostic messages, see perldiag. New DiagnosticsNew Errors
New Warnings
Changes to Existing Diagnostics
Configuration and Compilation
TestingTests were added and changed to reflect the other additions and changes in this release. Platform SupportWindows
VMS
Discontinued Platforms
Platform-Specific Notes
Internal Changes
For the first case (originally written as an integer), we now have: use Devel::Peek; my $answer = 42; Dump ($answer); my $void = "$answer"; print STDERR "\n"; Dump($answer) SV = IV(0x562538925778) at 0x562538925788 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 42 SV = PVIV(0x5625389263c0) at 0x562538925788 REFCNT = 1 FLAGS = (IOK,pIOK,pPOK) IV = 42 PV = 0x562538919b50 "42"\0 CUR = 2 LEN = 10 For the second (originally written as a string), we now have: use Devel::Peek; my $answer = "42"; Dump ($answer); my $void = $answer == 6 * 9; print STDERR "\n"; Dump($answer)' SV = PV(0x5586ffe9bfb0) at 0x5586ffec0788 REFCNT = 1 FLAGS = (POK,IsCOW,pPOK) PV = 0x5586ffee7fd0 "42"\0 CUR = 2 LEN = 10 COW_REFCNT = 1 SV = PVIV(0x5586ffec13c0) at 0x5586ffec0788 REFCNT = 1 FLAGS = (IOK,POK,IsCOW,pIOK,pPOK) IV = 42 PV = 0x5586ffee7fd0 "42"\0 CUR = 2 LEN = 10 COW_REFCNT = 1 (One can't rely on the presence or absence of the flag "SVf_IsCOW" to determine the history of operations on a scalar.) Previously both cases would be indistinguishable, with all 4 flags set: SV = PVIV(0x55d4d62edaf0) at 0x55d4d62f0930 REFCNT = 1 FLAGS = (IOK,POK,pIOK,pPOK) IV = 42 PV = 0x55d4d62e1740 "42"\0 CUR = 2 LEN = 10 (and possibly "SVf_IsCOW", but not always) This now means that if XS code really needs to determine which form a value was first written as, it should implement logic roughly if (flags & SVf_IOK|SVf_NOK) && !(flags & SVf_POK) serialize as number else if (flags & SVf_POK) serialize as string else the existing guesswork ... Note that this doesn't cover "dualvars" - scalars that report different values when asked for their string form or number form (such as $!). Most serialization formats cannot represent such duplicity. The existing guesswork remains because as well as dualvars, values might be "undef", references, overloaded references, typeglobs and other things that Perl itself can represent but do not map one-to-one into external formats, so need some amount of approximation or encapsulation.
Selected Bug Fixes
This inconsistency is now fixed - the internal state is now freed immediately by "untie". As the precise timing of this behaviour can be observed with pure Perl code (the timing of "DESTROY" on objects returned from "FIRSTKEY" and "NEXTKEY") it's just possible that some code is sensitive to it.
Errata From Previous Releases
ObituariesRaun "Spider" Boardman (SPIDB on CPAN), author of at least 66 commits to the Perl 5 core distribution between 1996 and 2002, passed away May 24, 2021 from complications of COVID. He will be missed. David H. Adler (DHA) passed away on November 16, 2021. In 1997, David co-founded NY.pm, the first Perl user group, and in 1998 co-founded Perl Mongers to help establish other user groups across the globe. He was a frequent attendee at Perl conferences in both North America and Europe and well known for his role in organizing Bad Movie Night celebrations at those conferences. He also contributed to the work of the Perl Foundation, including administering the White Camel awards for community service. He will be missed. AcknowledgementsPerl 5.36.0 represents approximately a year of development since Perl 5.34.0 and contains approximately 250,000 lines of changes across 2,000 files from 82 authors. Excluding auto-generated files, documentation and release tools, there were approximately 190,000 lines of changes to 1,300 .pm, .t, .c and .h files. Perl continues to flourish into its fourth decade thanks to a vibrant community of users and developers. The following people are known to have contributed the improvements that became Perl 5.36.0: Alyssa Ross, Andrew Fresh, Aristotle Pagaltzis, Asher Mancinelli, Atsushi Sugawara, Ben Cornett, Bernd, Biswapriyo Nath, Brad Barden, Bram, Branislav Zahradník, brian d foy, Chad Granum, Chris 'BinGOs' Williams, Christian Walde (Mithaldu), Christopher Yeleighton, Craig A. Berry, cuishuang, Curtis Poe, Dagfinn Ilmari Mannsåker, Dan Book, Daniel Laügt, Dan Jacobson, Dan Kogai, Dave Cross, Dave Lambley, David Cantrell, David Golden, David Marshall, David Mitchell, E. Choroba, Eugen Konkov, Felipe Gasper, François Perrad, Graham Knop, H.Merijn Brand, Hugo van der Sanden, Ilya Sashcheka, Ivan Panchenko, Jakub Wilk, James E Keenan, James Raspass, Karen Etheridge, Karl Williamson, Leam Hall, Leon Timmermans, Magnus Woldrich, Matthew Horsfall, Max Maischein, Michael G Schwern, Michiel Beijen, Mike Fulton, Neil Bowers, Nicholas Clark, Nicolas R, Niyas Sait, Olaf Alders, Paul Evans, Paul Marquess, Petar-Kaleychev, Pete Houston, Renee Baecker, Ricardo Signes, Richard Leach, Robert Rothenberg, Sawyer X, Scott Baker, Sergey Poznyakoff, Sergey Zhmylove, Sisyphus, Slaven Rezic, Steve Hay, Sven Kirmess, TAKAI Kousuke, Thibault Duponchelle, Todd Rinaldo, Tomasz Konojacki, Tomoyuki Sadahiro, Tony Cook, Unicode Consortium, Yves Orton, Михаил Козачков. The list above is almost certainly incomplete as it is automatically generated from version control history. In particular, it does not include the names of the (very much appreciated) contributors who reported issues to the Perl bug tracker. Many of the changes included in this version originated in the CPAN modules included in Perl's core. We're grateful to the entire CPAN community for helping Perl to flourish. For a more complete list of all of Perl's historical contributors, please see the AUTHORS file in the Perl source distribution. Reporting BugsIf you find what you think is a bug, you might check the perl bug database at <https://github.com/Perl/perl5/issues>. There may also be information at <http://www.perl.org/>, the Perl Home Page. If you believe you have an unreported bug, please open an issue at <https://github.com/Perl/perl5/issues>. Be sure to trim your bug down to a tiny but sufficient test case. If the bug you are reporting has security implications which make it inappropriate to send to a public issue tracker, then see "SECURITY VULNERABILITY CONTACT INFORMATION" in perlsec for details of how to report the issue. Give ThanksIf you wish to thank the Perl 5 Porters for the work we had done in Perl 5, you can do so by running the "perlthanks" program: perlthanks This will send an email to the Perl 5 Porters list with your show of thanks. SEE ALSOThe Changes file for an explanation of how to view exhaustive details on what changed. The INSTALL file for how to build Perl. The README file for general stuff. The Artistic and Copying files for copyright information.
|