X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperl5110delta.pod;h=ea62b67c57980581a1b9bca3ecfb8fb2e0d5daa1;hb=92a24ac3df5779ed0c9681cafefdd31fc6e1ae98;hp=65cfb94c44b5de9bd4de93020688b529415d8eae;hpb=7120b314ec81733a7037382ff358361096cdffa1;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perl5110delta.pod b/pod/perl5110delta.pod index 65cfb94..ea62b67 100644 --- a/pod/perl5110delta.pod +++ b/pod/perl5110delta.pod @@ -5,14 +5,122 @@ perldelta - what is new for perl v5.11.0 =head1 DESCRIPTION This document describes differences between the 5.10.0 and the 5.11.0 -developement releases. +development releases. =head1 Incompatible Changes +=head2 Switch statement changes + +The handling of complex expressions by the C/C switch +statement has been enhanced. There are two new cases where C now +inteprets its argument as a boolean, instead of an expression to be used +in a smart match: + +=over 4 + +=item flip-flop operators + +The C<..> and C<...> flip-flop operators are evaluated in boolean context, +following their usual semantics; see L. + +=item defined-or operator + +A compound expression involving the defined-or operator, as in +C, will be treated as boolean if the first +expression is boolean. (This just extends the existing rule that applies +to the regular or operator, as in C.) + +=back + +The next paragraph details more changes brought to the semantics to +the smart match operator, that naturally also modify the behaviour +of the switch statements where smart matching is implicitly used. + +=head2 Smart match changes + +=head3 Changes to type-based dispatch + +The smart match operator C<~~> is no longer commutative. The behaviour of +a smart match now depends primarily on the type of its right hand +argument. Moreover, its semantics has been adjusted for greater +consistency or usefulness in several cases. While the general backwards +compatibility is maintained, several changes must be noted: + +=over 4 + +=item * + +Code references with an empty prototype are no longer treated specially. +They are passed an argument like the other code references (even if they +choose to ignore it). + +=item * + +C<%hash ~~ sub {}> and C<@array ~~ sub {}> now test that the subroutine +returns a true value for each key of the hash (or element of the +array), instead of passing the whole hash or array as a reference to +the subroutine. + +=item * + +Due to the commutativity breakage, code references are no longer +treated specially when appearing on the left of the C<~~> operator, +but like any vulgar scalar. + +=item * + +C is always false (since C can't be a key in a +hash). No implicit conversion to C<""> is done (as was the case in perl +5.10.0). + +=item * + +C<$scalar ~~ @array> now always distributes the smart match across the +elements of the array. It's true if one element in @array verifies +C<$scalar ~~ $element>. This is a generalization of the old behaviour +that tested whether the array contained the scalar. + +=back + +The full dispatch table for the smart match operator is given in +L. + +=head3 Smart match and overloading + +According to the rule of dispatch based on the rightmost argument type, +when an object overloading C<~~> appears on the right side of the +operator, the overload routine will always be called (with a 3rd argument +set to a true value, see L.) However, when the object will +appear on the left, the overload routine will be called only when the +rightmost argument is a simple scalar. This way distributivity of smart match +across arrays is not broken, as well as the other behaviours with complex +types (coderefs, hashes, regexes). Thus, writers of overloading routines +for smart match mostly need to worry only with comparing against a scalar, +and possibly with stringification overloading; the other common cases +will be automatically handled consistently. + +C<~~> will now refuse to work on objects that do not overload it (in order +to avoid relying on the object's underlying structure). + =head1 Core Enhancements +=head1 The C pragma + +This pragma allows you to lexically disable or enable overloading +for some or all operations. (Yuval Kogman) + =head1 Modules and Pragmata +=head2 Pragmata Changes + +=over 4 + +=item C + +See L pragma"> above. + +=back + =head1 Utility Changes =head1 Documentation @@ -23,6 +131,15 @@ developement releases. =head1 Selected Bug Fixes +=over 4 + +=item C<-I> on shebang line now adds directories in front of @INC + +as documented, and as does C<-I> when specified on the command-line. +(Renée Bäcker) + +=back + =head1 New or Changed Diagnostics =head1 Changed Internals