X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Foverload.pm;h=e506a7c2d35787570e97255983edc61da8c4aecb;hb=7cb0cfe6b05b22a9c89198b7133aee5507599e8c;hp=d5ac5ad07345ba42aa7b3b3bc4e5cf88425f9445;hpb=0de1c906c34397b53c088e443cd0325d9c209649;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/overload.pm b/lib/overload.pm index d5ac5ad..e506a7c 100644 --- a/lib/overload.pm +++ b/lib/overload.pm @@ -1,6 +1,6 @@ package overload; -our $VERSION = '1.08'; +our $VERSION = '1.09'; sub nil {} @@ -9,6 +9,7 @@ sub OVERLOAD { my %arg = @_; my ($sub, $fb); $ {$package . "::OVERLOAD"}{dummy}++; # Register with magic by touching. + $fb = ${$package . "::()"}; # preserve old fallback value RT#68196 *{$package . "::()"} = \&nil; # Make it findable via fetchmethod. for (keys %arg) { if ($_ eq 'fallback') { @@ -134,7 +135,7 @@ sub mycan { # Real can would leave stubs. unary => "neg ! ~", mutators => '++ --', func => "atan2 cos sin exp abs log sqrt int", - conversion => 'bool "" 0+', + conversion => 'bool "" 0+ qr', iterators => '<>', filetest => "-X", dereferencing => '${} @{} %{} &{} *{}', @@ -399,15 +400,20 @@ floating-point-like types one should follow the same semantic. If C is unavailable, it can be autogenerated using the overloading of C<0+>. -=item * I +=item * I - 'bool', '""', '0+', + 'bool', '""', '0+', 'qr' -If one or two of these operations are not overloaded, the remaining ones can -be used instead. C is used in the flow control operators -(like C) and for the ternary C operation. These functions can -return any arbitrary Perl value. If the corresponding operation for this value -is overloaded too, that operation will be called again with this value. +If one or two of these operations are not overloaded, the remaining ones +can be used instead. C is used in the flow control operators +(like C) and for the ternary C operation; C is used for +the RHS of C<=~> and when an object is interpolated into a regexp. + +C, C<"">, and C<0+> can return any arbitrary Perl value. If the +corresponding operation for this value is overloaded too, that operation +will be called again with this value. C must return a compiled +regexp, or a ref to a compiled regexp (such as C returns), and any +further overloading on the return value will be ignored. As a special case if the overload returns the object itself then it will be used directly. An overloaded conversion returning the object is @@ -517,7 +523,7 @@ A computer-readable form of the above table is available in the hash unary => 'neg ! ~', mutators => '++ --', func => 'atan2 cos sin exp abs log sqrt', - conversion => 'bool "" 0+', + conversion => 'bool "" 0+ qr', iterators => '<>', filetest => '-X', dereferencing => '${} @{} %{} &{} *{}', @@ -692,8 +698,8 @@ is not defined. =item I -String, numeric, and boolean conversion are calculated in terms of one -another if not all of them are defined. +String, numeric, boolean and regexp conversion are calculated in terms +of one another if not all of them are defined. =item I