diff options
author | Ricardo Signes <rjbs@cpan.org> | 2015-03-13 19:12:36 -0400 |
---|---|---|
committer | Ricardo Signes <rjbs@cpan.org> | 2015-05-05 21:14:58 -0400 |
commit | c66edfb4d0e469c7f392a695d8d722a14b03ac5d (patch) | |
tree | ced0b6a5a337544b5d95569355a7fa22ac575801 /Porting | |
parent | 9fdefe17dfc99d6c18de62fdc2c9114fb96682ce (diff) | |
download | perl-c66edfb4d0e469c7f392a695d8d722a14b03ac5d.tar.gz |
perldelta: import changes from perl5216delta.pod
Diffstat (limited to 'Porting')
-rw-r--r-- | Porting/perl5220delta.pod | 366 |
1 files changed, 366 insertions, 0 deletions
diff --git a/Porting/perl5220delta.pod b/Porting/perl5220delta.pod index 81078d8ffc..7f0ce98dc7 100644 --- a/Porting/perl5220delta.pod +++ b/Porting/perl5220delta.pod @@ -29,6 +29,31 @@ On platforms that implement neither the C99 standard nor the POSIX 2001 standard, determining if the current locale is UTF8 or not depends on heuristics. These are improved in this release. +=head2 List form of pipe open implemented for Win32 + +The list form of pipe: + + open my $fh, "-|", "program", @arguments; + +is now implemented on Win32. It has the same limitations as C<system +LIST> on Win32, since the Win32 API doesn't accept program arguments +as a list. + +=head2 Assignment to list repetition + +C<(...) x ...> can now be used within a list that is assigned to, as long +as the left-hand side is a valid lvalue. This allows C<(undef,undef,$foo) += that_function()> to be written as C<((undef)x2, $foo) = that_function()>. + +=head2 C<close> now sets C<$!> + +When an I/O error occurs, the fact that there has been an error is recorded +in the handle. C<close> returns false for such a handle. Previously, the +value of C<$!> would be untouched by C<close>, so the common convention of +writing C<close $fh or die $!> did not work reliably. Now the handle +records the value of C<$!>, too, and C<close> restores it. + + =head2 Infinity and NaN (not-a-number) handling improved Floating point values are able to hold the special values infinity (also @@ -272,6 +297,60 @@ in a multi-byte character has been deprecated. Matching single bytes in a multi-byte character breaks encapsulation, and can corrupt utf8 strings. +=head2 Use of non-graphic characters in single-character variable names + +The syntax for single-character variable names is more lenient than +for longer variable names, allowing the one-character name to be a +punctuation character or even invisible (a non-graphic). Perl v5.20 +deprecated the ASCII-range controls as such a name. Now, all +non-graphic characters that formerly were allowed are deprecated. +The practical effect of this occurs only when not under C<S<"use +utf8">>, and affects just the C1 controls (code points 0x80 through +0xFF), NO-BREAK SPACE, and SOFT HYPHEN. + +=head2 Inlining of C<sub () { $var }> with observable side-effects + +In many cases Perl makes sub () { $var } into an inlinable constant +subroutine, capturing the value of $var at the time the C<sub> expression +is evaluated. This can break the closure behaviour in those cases where +$var is subsequently modified. The subroutine won't return the new value. + +This usage is now deprecated in those cases where the variable could be +modified elsewhere. Perl detects those cases and emits a deprecation +warning. Such code will likely change in the future and stop producing a +constant. + +If your variable is only modified in the place where it is declared, then +Perl will continue to make the sub inlinable with no warnings. + + sub make_constant { + my $var = shift; + return sub () { $var }; # fine + } + + sub make_constant_deprecated { + my $var; + $var = shift; + return sub () { $var }; # deprecated + } + + sub make_constant_deprecated2 { + my $var = shift; + log_that_value($var); # could modify $var + return sub () { $var }; # deprecated + } + +In the second example above, detecting that $var is assigned to only once +is too hard to detect. That it happens in a spot other than the C<my> +declaration is enough for Perl to find it suspicious. + +This deprecation warning happens only for a simple variable for the body of +the sub. (A C<BEGIN> block or C<use> statement inside the sub is ignored, +because it does not become part of the sub's body.) For more complex +cases, such as C<sub () { do_something() if 0; $var }> the behaviour has +changed such that inlining does not happen if the variable is modifiable +elsewhere. Such cases should be rare. + =head2 Use of multiple /x regexp modifiers It is now deprecated to say something like any of the following: @@ -338,6 +417,39 @@ as an updated module in the L</Modules and Pragmata> section. =item * +C<(...)x1>, C<("constant")x0> and C<($scalar)x0> are now optimised in list +context. If the right-hand argument is a constant 1, the repetition +operator disappears. If the right-hand argument is a constant 0, the whole +expressions is optimised to the empty list, so long as the left-hand +argument is a simple scalar or constant. C<(foo())x0> is not optimised. + +=item * + +C<substr> assignment is now optimised into 4-argument C<substr> at the end +of a subroutine (or as the argument to C<return>). Previously, this +optimisation only happened in void context. + +=item * + +Assignment to lexical variables is often optimised away. For instance, in +C<$lexical = chr $foo>, the C<chr> operator writes directly to the lexical +variable instead of returning a value that gets copied. This optimisation +has been extended to C<split>, C<x> and C<vec> on the right-hand side. It +has also been made to work with state variable initialization. + +=item * + +In "\L...", "\Q...", etc., the extra "stringify" op is now optimised away, +making these just as fast as C<lcfirst>, C<quotemeta>, etc. + +=item * + +Assignment to an empty list is now sometimes faster. In particular, it +never calls C<FETCH> on tied arguments on the right-hand side, whereas it +used to sometimes. + +=item * + C<length> is up to 20% faster for non-magical/non-tied scalars containing a string if it is a non-utf8 string or if C<use bytes;> is in scope. @@ -474,6 +586,17 @@ XXX Description of the purpose of the new file here =head2 Changes to Existing Documentation +=head3 L<perldata/Identifier parsing> + +=over 4 + +=item * + +The syntax of single-character variable names has been brought +up-to-date and more fully explained. + +=back + =head3 L<perlrecharclass> =over 4 @@ -857,6 +980,41 @@ L<Illegal suidscript|perldiag/"Illegal suidscript"> =item * +L<Use of literal non-graphic characters in variable names is deprecated|perldiag/"Use of literal non-graphic characters in variable names is deprecated"> + +=item * + +A new C<locale> warning category has been created, with the following warning +messages currently in it: + +=over 4 + +=item * + +L<Locale '%s' may not work well.%s|perldiag/Locale '%s' may not work well.%s> + +=item * + +L<Can't do %s("%s") on non-UTF-8 locale; resolved to "%s".|perldiag/Can't do %s("%s") on non-UTF-8 locale; resolved to "%s".> + +=back + +=item * + +L<Warning: unable to close filehandle %s properly: %s|perldiag/"Warning: unable to close filehandle %s properly: %s"> + +=item * + +The following two warnings for C<tr///> used to be skipped if the +transliteration contained wide characters, but now they occur regardless of +whether there are wide characters or not: + +L<Useless use of E<sol>d modifier in transliteration operator|perldiag/"Useless use of /d modifier in transliteration operator"> + +L<Replacement list is longer than search list|perldiag/Replacement list is longer than search list> + +=item * + L<Character in 'C' format overflow in pack|perldiag/"Character in 'C' format overflow in pack"> (W pack) You tried converting an infinity or not-a-number to an unsigned @@ -1130,6 +1288,10 @@ separate distributions (App::find2perl, App::s2p, App::a2p). =item * +F<Configure> with C<-Dmksymlinks> should now be faster. [perl #122002] + +=item * + For long doubles (to get more precision and range for floating point numbers) one can now use the GCC quadmath library which implements the quadruple precision floating point numbers in x86 and ia64 platforms. See F<INSTALL> for @@ -1265,8 +1427,27 @@ a fix for legacy feature checking status. =item Windows +=over 4 + +=item * + C<%I64d> is now being used instead of C<%lld> for MinGW. +=item * + +In the experimental C<:win32> layer, a crash in C<open> was fixed. Also +opening C</dev/null>, which works the Win32 Perl's normal C<:unix> layer, was +implemented for C<:win32>. +L<[perl #122224]|https://rt.perl.org/Ticket/Display.html?id=122224> + +=item * + +A new makefile option, C<USE_LONG_DOUBLE>, has been added to the Windows +dmake makefile for gcc builds only. Set this to "define" if you want perl to +use long doubles to give more accuracy and range for floating point numbers. + +=back + =item OpenBSD On OpenBSD, Perl will now default to using the system C<malloc> due to the @@ -1303,6 +1484,35 @@ as well as C<SUNWspro>, and support for native C<setenv> has been added. =item * +C<screaminstr> has been removed. Although marked as public API, it is +undocumented and has no usage in modern perl versions on CPAN Grep. Calling it +has been fatal since 5.17.0. + +=item * + +C<newDEFSVOP>, C<block_start>, C<block_end> and C<intro_my> have been added +to the API. + +=item * + +The internal C<convert> function in F<op.c> has been renamed +C<op_convert_list> and added to the API. + +=item * + +C<sv_magic> no longer forbids "ext" magic on read-only values. After all, +perl can't know whether the custom magic will modify the SV or not. +[perl #123103] + +=item * + +Starting in 5.21.6, accessing L<perlapi/CvPADLIST> in an XSUB is forbidden. +CvPADLIST has be reused for a different internal purpose for XSUBs. Guard all +CvPADLIST expressions with C<CvISXSUB()> if your code doesn't already block +XSUB CV*s from going through optree CV* expecting code. + +=item * + SVs of type SVt_NV are now bodyless when a build configure and platform allow it, specifically C<sizeof(NV) <= sizeof(IV)>. The bodyless trick is the same one as for IVs since 5.9.2, but for NVs, unlike IVs, is not guaranteed on all @@ -1479,6 +1689,162 @@ C<< -DPERL_OP_PARENT >> has been set, they return the parent of the current op. =item * +fchmod() and futimes() now set C<$!> when they fail due to being +passed a closed file handle. [perl #122703] + +=item * + +Perl now comes with a corrected Unicode 7.0 for the erratum issued on +October 21, 2014 (see L<http://www.unicode.org/errata/#current_errata>), +dealing with glyph shaping in Arabic. + +=item * + +op_free() no longer crashes due to a stack overflow when freeing a +deeply recursive op tree. [perl #108276] + +=item * + +scalarvoid() would crash due to a stack overflow when processing a +deeply recursive op tree. [perl #108276] + +=item * + +In Perl 5.20.0, C<$^N> accidentally had the internal UTF8 flag turned off +if accessed from a code block within a regular expression, effectively +UTF8-encoding the value. This has been fixed. [perl #123135] + +=item * + +A failed C<semctl> call no longer overwrites existing items on the stack, +causing C<(semctl(-1,0,0,0))[0]> to give an "uninitialized" warning. + +=item * + +C<else{foo()}> with no space before C<foo> is now better at assigning the +right line number to that statement. [perl #122695] + +=item * + +Sometimes the assignment in C<@array = split> gets optimised and C<split> +itself writes directly to the array. This caused a bug, preventing this +assignment from being used in lvalue context. So +C<(@a=split//,"foo")=bar()> was an error. (This bug probably goes back to +Perl 3, when the optimisation was added.) This optimisation, and the bug, +started to happen in more cases in 5.21.5. It has now been fixed. +[perl #123057] + +=item * + +When argument lists that fail the checks installed by subroutine +signatures, the resulting error messages now give the file and line number +of the caller, not of the called subroutine. [perl #121374] + +=item * + +Flip-flop operators (C<..> and C<...> in scalar context) used to maintain +a separate state for each recursion level (the number of times the +enclosing sub was called recursively), contrary to the documentation. Now +each closure has one internal state for each flip-flop. [perl #122829] + +=item * + +C<use>, C<no>, statement labels, special blocks (C<BEGIN>) and pod are now +permitted as the first thing in a C<map> or C<grep> block, the block after +C<print> or C<say> (or other functions) returning a handle, and within +C<${...}>, C<@{...}>, etc. [perl #122782] + +=item * + +The repetition operator C<x> now propagates lvalue context to its left-hand +argument when used in contexts like C<foreach>. That allows +C<for(($#that_array)x2) { ... }> to work as expected if the loop modifies +$_. + +=item * + +C<(...) x ...> in scalar context used to corrupt the stack if one operand +were an object with "x" overloading, causing erratic behaviour. +[perl #121827] + +=item * + +Assignment to a lexical scalar is often optimised away (as mentioned under +L</Performance Enhancements>). Various bugs related to this optimisation +have been fixed. Certain operators on the right-hand side would sometimes +fail to assign the value at all or assign the wrong value, or would call +STORE twice or not at all on tied variables. The operators affected were +C<$foo++>, C<$foo-->, and C<-$foo> under C<use integer>, C<chomp>, C<chr> +and C<setpgrp>. + +=item * + +List assignments were sometimes buggy if the same scalar ended up on both +sides of the assignment due to used of C<tied>, C<values> or C<each>. The +result would be the wrong value getting assigned. + +=item * + +C<setpgrp($nonzero)> (with one argument) was accidentally changed in 5.16 +to mean C<setpgrp(0)>. This has been fixed. + +=item * + +C<__SUB__> could return the wrong value or even corrupt memory under the +debugger (the B<-d> switch) and in subs containing C<eval $string>. + +=item * + +When C<sub () { $var }> becomes inlinable, it now returns a different +scalar each time, just as a non-inlinable sub would, though Perl still +optimises the copy away in cases where it would make no observable +difference. + +=item * + +C<my sub f () { $var }> and C<sub () : attr { $var }> are no longer +eligible for inlining. The former would crash; the latter would just +throw the attributes away. An exception is made for the little-known +":method" attribute, which does nothing much. + +=item * + +Inlining of subs with an empty prototype is now more consistent than +before. Previously, a sub with multiple statements, all but the last +optimised away, would be inlinable only if it were an anonymous sub +containing a string C<eval> or C<state> declaration or closing over an +outer lexical variable (or any anonymous sub under the debugger). Now any +sub that gets folded to a single constant after statements have been +optimised away is eligible for inlining. This applies to things like C<sub +() { jabber() if DEBUG; 42 }>. + +Some subroutines with an explicit C<return> were being made inlinable, +contrary to the documentation, Now C<return> always prevents inlining. + +=item * + +On some systems, such as VMS, C<crypt> can return a non-ASCII string. If a +scalar assigned to had contained a UTF8 string previously, then C<crypt> +would not turn off the UTF8 flag, thus corrupting the return value. This +would happen with C<$lexical = crypt ...>. + +=item * + +C<crypt> no longer calls C<FETCH> twice on a tied first argument. + +=item * + +An unterminated here-doc on the last line of a quote-like operator +(C<qq[${ <<END }]>, C</(?{ <<END })/>) no longer causes a double free. It +started doing so in 5.18. + +=item * + +Fixed two assertion failures introduced into C<-DPERL_OP_PARENT> +builds. [perl #108276] + +=item * + index() and rindex() no longer crash when used on strings over 2GB in size. L<[perl #121562]|https://rt.perl.org/Ticket/Display.html?id=121562>. |