This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perldelta for 978a498e (PL_sub_generation++)
[perl5.git] / pod / perldelta.pod
index f696818..4c95edf 100644 (file)
@@ -1,24 +1,19 @@
 =encoding utf8
 
-=for comment
-A Windows-specific commit that may need mention (does this have any
-user-visible effects?):
-0c38a57 Remove exports of dummy set[ug]id functions on Windows
-
 =head1 NAME
 
 [ 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.17.5
+perldelta - what is new for perl v5.17.7
 
 =head1 DESCRIPTION
 
-This document describes differences between the 5.17.4 release and the 5.17.5
+This document describes differences between the 5.17.6 release and the 5.17.7
 release.
 
-If you are upgrading from an earlier release such as 5.17.3, first read
-L<perl5174delta>, which describes differences between 5.17.3 and 5.17.4.
+If you are upgrading from an earlier release such as 5.17.5, first read
+L<perl5176delta>, which describes differences between 5.17.5 and 5.17.6.
 
 =head1 Notice
 
@@ -26,19 +21,11 @@ XXX Any important notices here
 
 =head1 Core Enhancements
 
-XXX New core language features go here.  Summarize user-visible core language
-enhancements.  Particularly prominent performance optimisations could go
-here, but most should go in the L</Performance Enhancements> section.
-
-[ List each enhancement as a =head2 entry ]
-
-=head2 Upgrade to Unicode 6.2
+=head2 $&, $` and $' are no longer slow
 
-Perl now supports the final version of Unicode 6.2.  Earlier releases in
-the 5.17 series supported Unicode 6.2 beta versions.  There were no
-substantive changes in the final Unicode 6.2 version from the most
-recent beta, included in Perl 5.17.4.  A list of changes from Unicode
-6.1 is at L<http://www.unicode.org/versions/Unicode6.2.0>.
+These three infamous variables have been redeemed and no longer slow down
+your program when used.  Hence, the /p regular expression flag now does
+nothing.
 
 =head1 Security
 
@@ -48,55 +35,28 @@ L</Selected Bug Fixes> section.
 
 [ List each security issue as a =head2 entry ]
 
-=head2 Avoid calling memset with a negative count
+=head1 Incompatible Changes
 
-Poorly written perl code that allows an attacker to specify the count to perl's
-C<x> string repeat operator can already cause a memory exhaustion
-denial-of-service attack. A flaw in versions of perl before 5.15.5 can escalate
-that into a heap buffer overrun; coupled with versions of glibc before 2.16, it
-possibly allows the execution of arbitrary code.
+=head2 readline() with C<$/ = \N> now reads N characters, not N bytes
 
-The flaw addressed to this commit has been assigned identifier CVE-2012-5195.
+Previously, when reading from a stream with I/O layers such as
+C<encoding>, the readline() function, otherwise known as the C<< <> >>
+operator, would read I<N> bytes from the top-most layer. [perl #79960]
 
-=head1 Incompatible Changes
+Now, I<N> characters are read instead.
+
+There is no change in behaviour when reading from streams with no
+extra layers, since bytes map exactly to characters.
 
-XXX For a release on a stable branch, this section aspires to be:
-
-    There are no changes intentionally incompatible with 5.XXX.XXX
-    If any exist, they are bugs, and we request that you submit a
-    report.  See L</Reporting Bugs> below.
-
-[ List each incompatible change as a =head2 entry ]
-
-=head2 New Restrictions in Multi-Character Case-Insensitive Matching in Regular Expression Bracketed Character Classes
-
-Unicode has now withdrawn their previous recommendation for regular
-expressions to automatically handle cases where a single character can
-match multiple characters case-insensitively; for example, the letter
-LATIN SMALL LETTER SHARP S and the sequence C<ss>.  This is because
-it turns out to be impracticable to do this correctly in all
-circumstances.  Because Perl has tried to do this as best it can, it
-will continue to do so.  (We are considering an option to turn it off.)
-However, a new restriction is being added on such matches when they
-occur in [bracketed] character classes.  People were specifying
-things such as C</[\0-\xff]/i>, and being surprised that it matches the
-two character sequence C<ss> (since LATIN SMALL LETTER SHARP S occurs in
-this range).  This behavior is also inconsistent with the using a
-property instead of a range:  C<\p{Block=Latin1}> also includes LATIN
-SMALL LETTER SHARP S, but C</[\p{Block=Latin1}]/i> does not match C<ss>.
-The new rule is that for there to be a multi-character case-insensitive
-match within a bracketed character class, the character must be
-explicitly listed, and not as an end point of a range.  This more
-closely obeys the Principle of Least Astonishment.  See
-L<perlrecharclass/Bracketed Character Classes>.  Note that a bug [perl
-#89774], now fixed as part of this change, prevented the previous
-behavior from working fully.
-
-=head2 Change to Warnings About Lexical Subroutines
-
-The warnings category for lexical subroutines is now
-"experimental::lexical_subs", with two colons, not
-"experimental:lexical_subs";
+=head2 Lexical subroutine warnings have moved
+
+The warning about the use of an experimental feature emitted when lexical
+subroutines (added in 5.17.4) are used now happens when the subroutine
+itself is declared, not when the "lexical_subs" feature is activated via
+C<use feature>.
+
+This stops C<use feature ':all'> from warning, but causes
+C<my sub foo; my sub bar> to warn twice.
 
 =head1 Deprecations
 
@@ -106,6 +66,41 @@ an updated module in the L</Modules and Pragmata> section.
 
 [ List each deprecation as a =head2 entry ]
 
+=head2 Various XS-callable functions are now deprecated
+
+The following functions will be removed from a future version of Perl,
+and should not be used.  With participating C compilers (e.g., gcc),
+compiling any file that uses any of these will generate a warning.
+These were not intended for public use; there are equivalent, faster,
+macros for most of them.  See L<perlapi/Character classes>:
+C<is_uni_ascii>,
+C<is_uni_ascii_lc>,
+C<is_uni_blank>,
+C<is_uni_blank_lc>,
+C<is_uni_cntrl>,
+C<is_uni_cntrl_lc>,
+C<is_uni_idfirst_lc>,
+C<is_uni_space>,
+C<is_uni_space_lc>,
+C<is_uni_xdigit>,
+C<is_uni_xdigit_lc>,
+C<is_utf8_ascii>,
+C<is_utf8_blank>,
+C<is_utf8_cntrl>,
+C<is_utf8_idcont>,
+C<is_utf8_idfirst>,
+C<is_utf8_perl_space>,
+C<is_utf8_perl_word>,
+C<is_utf8_posix_digit>,
+C<is_utf8_space>,
+C<is_utf8_xdigit>.
+C<is_utf8_xidcont>,
+C<is_utf8_xidfirst>,
+C<to_uni_lower_lc>,
+C<to_uni_title_lc>,
+and
+C<to_uni_upper_lc>.
+
 =head1 Performance Enhancements
 
 XXX Changes which enhance performance without changing behaviour go here.
@@ -117,7 +112,11 @@ There may well be none in a stable release.
 
 =item *
 
-XXX
+Perl has a new copy-on-write mechanism that avoids the need to copy the
+internal string buffer when assigning from one scalar to another.  This
+makes copying large strings appear much faster.  Modifying one of the two
+(or more) strings after an assignment will force a copy internally.  This
+makes it unnecessary to pass strings by reference for efficiency.
 
 =back
 
@@ -149,131 +148,13 @@ XXX
 
 =item *
 
-L<AutoLoader> has been upgraded from version 5.72 to 5.73.
-
-=item *
-
-L<B::Deparse> has been upgraded from version 1.17 to 1.18.  It no longer
-dies when deparsing C<sort> without arguments.  It now correctly omits the
-comma for C<system $prog @args> and C<exec $prog @args>.
-
-=item *
-
-L<bignum>, L<bigint> and L<bigrat> have been upgraded from version 0.30 to
-0.31.  The overrides for C<hex> and C<oct> have been rewritten, eliminating
-several problems, and making one incompatible change:
-
-=over
-
-=item *
-
-Formerly, whichever of C<use bigint> or C<use bigrat> was compiled later
-would take precedence over the other, causing C<hex> and C<oct> not to
-respect the other pragma when in scope.
-
-=item *
-
-Using any of these three pragmata would cause C<hex> and C<oct> anywhere
-else in the program to evalute their arguments in list context and prevent
-them from inferring $_ when called without arguments.
-
-=item *
-
-Using any of these three pragmata would make C<oct("1234")> return 1234
-(for any number not beginning with 0) anywhere in the program.  Now "1234"
-is translated from octal to decimal, whether within the pragma's scope or
-not.
-
-=item *
-
-The global overrides that facilitate lexical use of C<hex> and C<oct> now
-respect any existing overrides that were in place before the new overrides
-were installed, falling back to them outside of the scope of C<use bignum>.
-
-=item *
-
-C<use bignum "hex">, C<use bignum "oct"> and similar invocations for bigint
-and bigrat now export a C<hex> or C<oct> function, instead of providing a
-global override.
-
-=back
-
-=item *
-
-L<Carp> has been upgraded from version 1.26 to 1.27.  The C<longmess()> and
-C<shortmess()> functions are now documented.
-
-=item *
-
-L<CPAN> has been upgraded from version 1.98 to 1.99_51.
-
-=item *
-
-L<CPANPLUS> has been upgraded from version 0.9131 to 0.9133.
-
-=item *
-
-L<Data::Dumper> has been upgraded from version 2.135_07 to 2.136.  This promotes
-the previous development release to a stable release.
-
-=item *
-
-L<Digest::SHA> has been upgraded from version 5.71 to 5.72.
-
-=item *
-
-L<ExtUtils::CBuilder> has been upgraded from version 0.280208 to 0.280209.  A
-list of symbols to export can now be passed to C<link()> when on Windows, as on
-other OSes [perl #115100].
-
-=item *
-
-L<feature> has been upgraded from version 1.30 to 1.31.
-
-=item *
-
-L<File::Glob> has been upgraded from version 1.17 to 1.18.  A
-space-separated list of patterns return long lists of results no longer
-results in memory corruption or crashes.  This bug was introduced in Perl
-5.16.0.  [perl #114984]
-
-=item *
-
-L<HTTP::Tiny> has been upgraded from version 0.022 to 0.024.  This improves
-SSL support.
-
-=item *
-
-L<Module::CoreList> has been upgraded from version 2.73 to 2.74.
-
-=item *
-
-L<PerlIO::encoding> has been upgraded from version 0.15 to 0.16.  This is
-the module implementing the ":encoding(...)" I/O layer.  It no longer
-corrupts memory or crashes when the encoding back-end reallocates the
-buffer or gives it a typeglob or shared hash key scalar.
-
-=item *
-
-L<threads::shared> has been upgraded from version 1.41 to 1.42.  This adds
-support for dual-valued values as created by
-L<Scalar::Util::dualvar|Scalar::Util/"dualvar NUM, STRING">.
-
-=item *
-
-L<Unicode::Collate> hsa been upgraded from version 0.89 to 0.90.
-
-=item *
-
-L<Unicode::Normalize> has been upgraded from version 1.14 to 1.15.
-
-=item *
-
-L<warnings> has been upgraded from version 1.14 to 1.15.
-
-=item *
-
-L<Win32CORE> has been upgraded from version 0.03 to 0.04.
+L<GDBM_File> has been upgraded from version 1.14 to 1.15. The undocumented
+optional fifth parameter to C<TIEHASH> has been removed. This was intended
+to provide control of the callback used by C<gdbm*> functions in case of
+fatal errors (such as filesystem problems), but did not work (and could
+never have worked). No code on CPAN even attempted to use it. The callback
+is now always the previous default, C<croak>. Problems on some platforms with
+how the C<C> C<croak> function is called have also been resolved.
 
 =back
 
@@ -306,13 +187,16 @@ XXX Changes which significantly change existing files in F<pod/> go here.
 However, any changes to F<pod/perldiag.pod> should go in the L</Diagnostics>
 section.
 
-=head3 L<XXX>
+=head3 L<perlapi/Character classes>
 
 =over 4
 
 =item *
 
-XXX Description of the change here
+There are quite a few macros callable from XS modules that classify
+characters into things like alphabetic, punctuation, etc.  More of these
+are now documented, including ones which work on characters whose code
+points are outside the Latin-1 range.
 
 =back
 
@@ -358,9 +242,7 @@ XXX Changes (i.e. rewording) of diagnostic messages go here
 
 =item *
 
-The error produced when a module cannot be loaded now includes a hint that
-the module may need to be installed: "Can't locate hopping.pm in @INC (you
-may need to install the hopping module) (@INC contains: ...)"
+XXX Describe change here
 
 =back
 
@@ -373,13 +255,13 @@ Most of these are built within the directories F<utils> and F<x2p>.
 entries for each change
 Use L<XXX> with program names to get proper documentation linking. ]
 
-=head3 L<h2xs>
+=head3 L<XXX>
 
 =over 4
 
 =item *
 
-F<h2xs> no longer produces invalid code for empty defines.  [perl #20636]
+XXX
 
 =back
 
@@ -442,13 +324,11 @@ XXX
 
 =head2 Discontinued Platforms
 
-XXX List any platforms that this version of perl no longer compiles on.
-
 =over 4
 
-=item MPE/IX
+=item BeOS
 
-Support for MPE/IX has been removed.
+Support for BeOS has been removed.
 
 =back
 
@@ -461,9 +341,9 @@ L</Modules and Pragmata> section.
 
 =over 4
 
-=item Win32
+=item XXX-some-platform
 
-The option to build without USE_SOCKETS_AS_HANDLES has been removed.
+XXX
 
 =back
 
@@ -479,55 +359,55 @@ well.
 
 =item *
 
-Case-insensitive matching inside a [bracketed] character class with a
-multi-character fold, no longer excludes one of the possibilities in the
-circumstances that it used to. [perl #89774].
+SvUPGRADE() is no longer an expression. Originally this macro (and its
+underlying function, sv_upgrade()) were documented as boolean, although
+in reality they always croaked on error and never returned false. In 2005
+the documentation was updated to specify a void return value, but
+SvUPGRADE() was left always returning 1 for backwards compatibility. This
+has now been removed, and SvUPGRADE() is now a statement with no return
+value.
 
-=item *
+So this is now a syntax error:
 
-C<PL_formfeed> has been removed.
+    if (!SvUPGRADE(sv)) { croak(...); }
 
-=item *
+If you have code like that, simply replace it with
 
-The regular expression engine no longer reads one byte past the end of the
-target string.  While for all internally well-formed scalars this should
-never have been a problem, this change facilitates clever tricks with
-string buffers in CPAN modules.  [perl #73542]
+    SvUPGRADE(sv);
 
-=item *
+or to to avoid compiler warnings with older perls, possibly
 
-Inside a BEGIN block, C<PL_compcv> now points to the currently-compiling
-subroutine, rather than the BEGIN block itself.
+    (void)SvUPGRADE(sv);
 
 =item *
 
-C<mg_length> has been deprecated.
+Perl has a new copy-on-write mechanism that allows any SvPOK scalar to be
+upgraded to a copy-on-write scalar.  A reference count on the string buffer
+is stored in the string buffer itself.
 
-=item *
+This breaks a few XS modules by allowing copy-on-write scalars to go
+through code paths that never encountered them before.
 
-C<sv_len> now always returns a byte count and C<sv_len_utf8> a character
-count.  Previously, C<sv_len> and C<sv_len_utf8> were both buggy and would
-sometimes returns bytes and sometimes characters.  C<sv_len_utf8> no longer
-assumes that its argument is in UTF8.  Neither of these creates UTF8 caches
-for tied or overloaded values or for non-PVs any more.
+This behaviour can still be disabled by running F<Configure> with
+B<-Accflags=-DPERL_NO_COW>.  This option will probably be removed in Perl
+5.20.
 
 =item *
 
-C<sv_mortalcopy> now copies string buffers of shared hash key scalars when
-called from XS modules [perl #79824].
+Copy-on-write no longer uses the SvFAKE and SvREADONLY flags.  Hence,
+SvREADONLY indicates a true read-only SV.
 
-=item *
-
-C<RXf_SPLIT> and C<RXf_SKIPWHITE> are no longer used.  They are now
-#defined as 0.
+Use the SvIsCOW macro (as before) to identify a copy-on-write scalar.
 
 =item *
 
-The new C<RXf_MODIFIES_VARS> flag can be set by custom regular expression
-engines to indicate that the execution of the regular expression may cause
-variables to be modified.  This lets C<s///> know to skip certain
-optimisations.  Perl's own regular expression engine sets this flag for the
-special backtracking verbs that set $REGMARK and $REGERROR.
+C<PL_sawampersand> is now a constant.  The switch this variable provided
+(to enable/disable the pre-match copy depending on whether C<$&> had been
+seen) has been removed and replaced with copy-on-write, eliminating a few
+bugs.
+
+The previous behaviour can still be enabled by running F<Configure> with
+B<-Accflags=-DPERL_SAWAMPERSAND>.
 
 =back
 
@@ -542,178 +422,51 @@ files in F<ext/> and F<lib/> are best summarized in L</Modules and Pragmata>.
 
 =item *
 
-A bug, case-insensitive regex with UTF8-flagged strings, introduced
-earlier in the 5.17 series has been fixed.  [perl #114982]
-
-=item *
-
-Attributes applied to lexical variables no longer leak memory.
-[perl #114764]
-
-=item *
-
-C<dump>, C<goto>, C<last>, C<next>, C<redo> or C<require> followed by a
-bareword (or version) and then an infix operator is no longer a syntax
-error.  It used to be for those infix operators (like C<+>) that have a
-different meaning where a term is expected.  [perl #105924]
-
-=item *
-
-C<require a::b . 1> and C<require a::b + 1> no longer produce erroneous
-ambiguity warnings.  [perl #107002]
-
-=item *
-
-Class method calls are now allowed on any string, and not just strings
-beginning with an alphanumeric character.  [perl #105922]
-
-=item *
-
-An empty pattern created with C<qr//> used in C<m///> no longer triggers
-the "empty pattern reuses last pattern" behaviour.  [perl #96230]
-
-=item *
-
-Tying a hash during iteration no longer results in a memory leak.
-
-=item *
-
-Freeing a tied hash during iteration no longer results in a memory leak.
-
-=item *
-
-List assignment to a tied array or hash that dies on STORE no longer
-results in a memory leak.
-
-=item *
-
-If the hint hash (C<%^H>) is tied, compile-time scope entry (which copies
-the hint hash) no longer leaks memory if FETCH dies.  [perl #107000]
-
-=item *
-
-Constant folding no longer inappropriately triggers the special
-C<split " "> behaviour.  [perl #94490]
-
-=item *
-
-C<defined scalar(@array)>, C<defined do { &foo }>, and similar constructs
-now treat the argument to C<defined> as a simple scalar.  [perl #97466]
-
-=item *
-
-Running a custom debugging that defines no C<*DB::DB> glob or provides a
-subroutine stub for C<&DB::DB> no longer results in a crash, but an error
-instead.  [perl #114990]
-
-=item *
-
-C<reset ""> now matches its documentation.  C<reset> only resets C<m?...?>
-patterns when called with no argument.  An empty string for an argument now
-does nothing.  (It used to be treated as no argument.)  [perl #97958]
-
-=item *
-
-C<printf> with an argument returning an empty list no longer reads past the
-end of the stack, resulting in erratic behaviour.  [perl #77094]
-
-=item *
-
-C<--subname> no longer produces erroneous ambiguity warnings.
-[perl #77240]
-
-=item *
-
-C<v10> is now allowed as a label or package name.  This was inadvertently
-broken when v-strings were added in Perl 5.6.  [perl #56880]
-
-=item *
-
-A regression introduced in 5.17.2 has been fixed, which made C</[\@\\]||/>
-result in a "panic" error.  [perl #115050]
-
-=item *
-
-C<length>, C<pos>, C<substr> and C<sprintf> could be confused by ties,
-overloading, references and typeglobs if the stringification of such
-changed the internal representation to or from UTF8.  [perl #114410]
-
-=item *
-
-utf8::encode now calls FETCH and STORE on tied variables.  utf8::decode now
-calls STORE (it was already calling FETCH).
+C<sort {undef} ...> under fatal warnings no longer crashes.  It started
+crashing in Perl 5.16.
 
 =item *
 
-C<$tied =~ s/$non_utf8/$utf8/> no longer loops infinitely if the tied
-variable returns a Latin-1 string, shared hash key scalar, or reference or
-typeglob that stringifies as ASCII or Latin-1.  This is a regression from
-5.12.x.
+Stashes blessed into each other
+(C<bless \%Foo::, 'Bar'; bless \%Bar::, 'Foo'>) no longer result in double
+frees.  This bug started happening in Perl 5.16.
 
 =item *
 
-C<s///> without /e is now better at detecting when it needs to forego
-certain optimisations, fixing some buggy cases:
-
-=over
+Numerous memory leaks have been fixed, mostly involving fatal warnings and
+syntax errors.
 
 =item *
 
-Match variables in certain constructs (C<&&>, C<||>, C<..> and others) in
-the replacement part; e.g., C<s/(.)/$l{$a||$1}/g>.  [perl #26986]
+Lexical constants (C<my sub answer () { 42 }>) no longer cause double
+frees.
 
 =item *
 
-Aliases to match variables in the replacement.
+Constant subroutine redefinition warns by default, but lexical constants
+were accidentally exempt from default warnings.  This has been corrected.
 
 =item *
 
-$REGERROR or $REGMARK in the replacement.  [perl #49190]
-
-=item *
-
-An empty pattern (C<s//$foo/>) that causes the last-successful pattern to
-be used, when that pattern contains code blocks that modify the variables
-in the replacement.
-
-=back
+Some failed regular expression matches such as C<'f' =~ /../g> were not
+resetting C<pos>.  Also, "match-once" patterns (C<m?...?g>) failed to reset
+it, too, when invoked a second time [perl #23180].
 
 =item *
 
-The taintedness of the replacement string no longer affects the taintedness
-of the return value of C<s///e>.
+Accessing C<$&> after a pattern match now works if it had not been seen
+before the match.  I.e., this applies to C<${'&'}> (under C<no strict>) and
+C<eval '$&'>.  The same applies to C<$'> and C<$`> [perl #4289].
 
 =item *
 
-The C<$|> autoflush variable is created on-the-fly when needed.  If this
-happened (e.g., if it was mentioned in a module or eval) when the
-currently-selected filehandle was a typeglob with an empty IO slot, it used
-to crash.  [perl #115206]
+Two minor bugs involving C<local *ISA> and C<local *Foo::> causing stale
+MRO caches have been fixed.  
 
 =item *
 
-Line numbers at the end of a string eval are no longer off by one.
-[perl #114658]
-
-=item *
-
-@INC filters (subroutines returned by subroutines in @INC) that set $_ to a
-copy-on-write scalar no longer cause the parser to modify that string
-buffer in place.
-
-=item *
-
-C<length($object)> no longer returns the undefined value if the object has
-string overloading that returns undef.  [perl #115260]
-
-=item *
-
-The use of C<PL_stashcache>, the stash name lookup cache for method calls, has
-been restored,
-
-Commit da6b625f78f5f133 in August 2011 inadvertently broke the code that looks
-up values in C<PL_stashcache>. As it's a only cache, quite correctly everything
-carried on working without it.
+Defining a subroutine when its typeglob has been aliased no longer results
+in stale method caches.  This bug was introduced in Perl 5.10.
 
 =back
 
@@ -742,7 +495,7 @@ here.
 
 XXX Generate this with:
 
-  perl Porting/acknowledgements.pl v5.17.4..HEAD
+  perl Porting/acknowledgements.pl v5.17.6..HEAD
 
 =head1 Reporting Bugs