This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
initialisation of simple aggregate state variables
[perl5.git] / pod / perldelta.pod
index 57b65c1..e1e608c 100644 (file)
@@ -5,15 +5,15 @@
 [ this is a template for a new perldelta file.  Any text flagged as XXX needs
 to be processed before release. ]
 
-perldelta - what is new for perl v5.27.2
+perldelta - what is new for perl v5.27.6
 
 =head1 DESCRIPTION
 
-This document describes differences between the 5.27.1 release and the 5.27.2
+This document describes differences between the 5.27.5 release and the 5.27.6
 release.
 
-If you are upgrading from an earlier release such as 5.27.0, first read
-L<perl5271delta>, which describes differences between 5.27.0 and 5.27.1.
+If you are upgrading from an earlier release such as 5.27.4, first read
+L<perl5275delta>, which describes differences between 5.27.4 and 5.27.5.
 
 =head1 Notice
 
@@ -27,10 +27,11 @@ here, but most should go in the L</Performance Enhancements> section.
 
 [ List each enhancement as a =head2 entry ]
 
-=head2 Unicode 10.0 is supported
+=head2 Initialisation of aggregate state variables
 
-A list of changes is at
-L<http://www.unicode.org/versions/Unicode10.0.0>.
+A persistent lexical array or hash variable can now be initialized,
+by an expression such as C<state @a = qw(x y z)>.  Initialization of a
+list of persistent lexical variables is still not possible.
 
 =head1 Security
 
@@ -88,13 +89,43 @@ as an updated module in the L</Modules and Pragmata> section.
 XXX Changes which enhance performance without changing behaviour go here.
 There may well be none in a stable release.
 
-[ List each enhancement as a =item entry ]
+[ List each enhancement as an =item entry ]
 
 =over 4
 
 =item *
 
-XXX
+Many string concatenation expressions are now considerably faster, due
+to the introduction internally of a C<multiconcat> opcode which combines
+multiple concatenations, and optionally a C<=> or C<.=>, into a single
+action. For example, apart from retrieving C<$s>, C<$a> and C<$b>, this
+whole expression is now handled as a single op:
+
+    $s .= "a=$a b=$b\n"
+
+As a special case, if the LHS of an assign is a lexical variable or
+C<my $s>, the op itself handles retrieving the lexical variable, which
+is faster.
+
+In general, the more the expression includes a mix of constant strings and
+variable expressions, the longer the expression, and the more it mixes
+together non-utf8 and utf8 strings, the more marked the performance
+improvement. For example on a C<x86_64> system, this code has been
+benchmarked running four times faster:
+
+    my $s;
+    my $a = "ab\x{100}cde";
+    my $b = "fghij";
+    my $c = "\x{101}klmn";
+
+    for my $i (1..10_000_000) {
+        $s = "\x{100}wxyz";
+        $s .= "foo=$a bar=$b baz=$c";
+    }
+
+In addition, C<sprintf> expressions which have a constant format
+containing only C<%s> and C<%%> format elements, and which have a fixed
+number of arguments, are now also optimised into a C<multiconcat> op.
 
 =back
 
@@ -106,7 +137,13 @@ following sections using F<Porting/corelist-perldelta.pl>.  A paragraph summary
 for important changes should then be added by hand.  In an ideal world,
 dual-life modules would have a F<Changes> file that could be cribbed.
 
-[ Within each section, list entries as a =item entry ]
+The list of new and updated modules is modified automatically as part of
+preparing a Perl release, so the only reason to manually add entries here is if
+you're summarising the important changes in the module update. (Also, if the
+manually-added details don't match the automatically-generated ones, the
+release manager will have to investigate the situation carefully.)
+
+[ Within each section, list entries as an =item entry ]
 
 =head2 New Modules and Pragmata
 
@@ -124,11 +161,10 @@ XXX
 
 =item *
 
-L<XXX> has been upgraded from version A.xx to B.yy.
-
-=item *
+L<Carp> has been upgraded from version 1.43 to 1.44.
 
-L<ExtUtils::CBuilder> has been upgraded from version 0.280225 to 0.280226.
+If a package on the call stack contains a constant named C<ISA>, Carp no
+longer throws a "Not a GLOB reference" error.
 
 =back
 
@@ -167,7 +203,15 @@ section.
 
 Additionally, the following selected changes have been made:
 
-=head3 L<XXX>
+=head3 L<perldiag/Variable length lookbehind not implemented in regex m/%s/>
+
+This now gives more ideas as to workarounds to the issue that was
+introduced in Perl 5.18 (but not documented explicitly in its perldelta)
+for the fact that some Unicode C</i> rules cause a few sequences such as
+
+ (?<!st)
+
+to be considered variable length, and hence disallowed.
 
 =over 4
 
@@ -219,6 +263,13 @@ XXX Changes (i.e. rewording) of diagnostic messages go here
 
 =item *
 
+The diagnostic C<Initialization of state variables in list context
+currently forbidden> has changed to C<Initialization of state variables
+in list currently forbidden>, because list-context initialization of
+single aggregate state variables is now permitted.
+
+=item *
+
 XXX Describe change here
 
 =back
@@ -249,13 +300,39 @@ go here.  Any other changes to the Perl build process should be listed here.
 However, any platform-specific changes should be listed in the
 L</Platform Support> section, instead.
 
-[ List changes as a =item entry ].
+[ List changes as an =item entry ].
 
 =over 4
 
-=item *
+=item New probes
 
-XXX
+=over 2
+
+=item HAS_BUILTIN_ADD_OVERFLOW
+
+=item HAS_BUILTIN_MUL_OVERFLOW
+
+=item HAS_BUILTIN_SUB_OVERFLOW
+
+=item HAS_THREAD_SAFE_NL_LANGINFO_L
+
+=item HAS_LOCALECONV_L
+
+=item HAS_MBRLEN
+
+=item HAS_MBRTOWC
+
+=item HAS_MEMRCHR
+
+=item HAS_NANOSLEEP
+
+=item HAS_STRNLEN
+
+=item HAS_STRTOLD_L
+
+=item I_WCHAR
+
+=back
 
 =back
 
@@ -278,7 +355,7 @@ Tests were added and changed to reflect the other additions and
 changes in this release.  Furthermore, these significant changes were
 made:
 
-[ List each test improvement as a =item entry ]
+[ List each test improvement as an =item entry ]
 
 =over 4
 
@@ -292,7 +369,7 @@ XXX
 
 XXX Any changes to platform support should be listed in the sections below.
 
-[ Within the sections, list each platform as a =item entry with specific
+[ Within the sections, list each platform as an =item entry with specific
 changes as paragraphs below it. ]
 
 =head2 New Platforms
@@ -343,13 +420,32 @@ XXX Changes which affect the interface available to C<XS> code go here.  Other
 significant internal changes for future core maintainers should be noted as
 well.
 
-[ List each change as a =item entry ]
+[ List each change as an =item entry ]
 
 =over 4
 
 =item *
 
-XXX
+A new optimisation phase has been added to the compiler,
+C<optimize_optree()>, which does a top-down scan of a complete optree
+just before the peephole optimiser is run. This phase is not currently
+hookable.
+
+=item *
+
+An C<OP_MULTICONCAT> op has been added. At C<optimize_optree()> time, a
+chain of C<OP_CONCAT> and C<OP_CONST> ops, together optionally with an
+C<OP_STRINGIFY> and/or C<OP_SASSIGN>, are combined into a single
+C<OP_MULTICONCAT> op. The op is of type C<UNOP_AUX>, and the aux array
+contains the argument count, plus a pointer to a constant string and a set
+of segment lengths. For example with
+
+    my $x = "foo=$foo, bar=$bar\n";
+
+the constant string would be C<"foo=, bar=\n"> and the segment lengths
+would be (4,6,1). If the string contains characters such as C<\x80>, whose
+representation changes under utf8, two sets of strings plus lengths are
+precomputed and stored.
 
 =back
 
@@ -358,50 +454,32 @@ XXX
 XXX Important bug fixes in the core language are summarized here.  Bug fixes in
 files in F<ext/> and F<lib/> are best summarized in L</Modules and Pragmata>.
 
-[ List each fix as a =item entry ]
+[ List each fix as an =item entry ]
 
 =over 4
 
 =item *
 
-List assignment (C<aassign>) could in some rare cases allocate an
-entry on the mortal stack and leave the entry uninitialized. [perl
-#131570]
-
-=item *
-
-Attempting to apply an attribute to an C<our> variable where a
-function of that name already exists could result in a NULL pointer
-being supplied where an SV was expected, crashing perl.  [perl
-#131597]
-
-=item *
-
-C<split ' '> now correctly handles the argument being split when in the
-scope of the L<< C<unicode_strings>|feature/"The 'unicode_strings' feature"
->> feature. Previously, when a string using the single-byte internal
-representation contained characters that are whitespace by Unicode rules but
-not by ASCII rules, it treated those characters as part of fields rather
-than as field separators.  [perl #130907]
+C<stat()>, C<lstat()>, and file test operators now fail if given a
+filename containing a nul character, in the same way that C<open()>
+already fails.
 
 =item *
 
-Several built-in functions previously had bugs that could cause them to
-write to the internal stack without allocating room for the item being
-written. In rare situations, this could have led to a crash. These bugs have
-now been fixed, and if any similar bugs are introduced in future, they will
-be detected automatically in debugging builds.
+The in-place reverse optimisation now correctly strengthens weak
+references using the L<C<sv_rvunweaken()>|perlapi/sv_rvunweaken>
+API function.
 
 =item *
 
-Using a symbolic ref with postderef syntax as the key in a hash lookup was
-yielding an assertion failure on debugging builds. [perl #131627]
+Fixed a read before buffer when parsing a range starting with C<\N{}>
+at the beginning of the character set for the transliteration
+operator.  [perl #132245]
 
 =item *
 
-Array and hash variables whose names begin with a caret now admit indexing
-inside their curlies when interpolated into strings, as in C<<
-"${^CAPTURE[0]}" >> to index C<@{^CAPTURE}>.  [perl #131664]
+Fixed a leaked SV when parsing an empty C<\N{}> at compile-time.
+[perl #132245]
 
 =back
 
@@ -411,7 +489,7 @@ XXX Descriptions of platform agnostic bugs we know we can't fix go here.  Any
 tests that had to be C<TODO>ed for the release would be noted here.  Unfixed
 platform specific bugs also go here.
 
-[ List each fix as a =item entry ]
+[ List each fix as an =item entry ]
 
 =over 4
 
@@ -441,7 +519,7 @@ here.
 
 XXX Generate this with:
 
-  perl Porting/acknowledgements.pl v5.25.5..HEAD
+  perl Porting/acknowledgements.pl v5.27.5..HEAD
 
 =head1 Reporting Bugs