From: Rafael Garcia-Suarez Date: Mon, 1 Jun 2009 15:16:40 +0000 (+0200) Subject: Smart-match perldelta adjustments X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ee18cc6c23aec0f5d3920503dd1095fc44b28aa3;p=p5sagit%2Fp5-mst-13.2.git Smart-match perldelta adjustments --- diff --git a/pod/perl5110delta.pod b/pod/perl5110delta.pod index 54292e0..ea62b67 100644 --- a/pod/perl5110delta.pod +++ b/pod/perl5110delta.pod @@ -42,8 +42,9 @@ of the switch statements where smart matching is implicitly used. 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. While the general backwards compatibility is maintained, -several changes must be noted: +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 @@ -62,6 +63,12 @@ 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). @@ -88,9 +95,9 @@ 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 need to worry only with comparing against a scalar, and -possibly with stringification overloading; the other cases will be -automatically handled consistently. +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).