summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/overload.pm
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-04-05 22:27:26 +0000
committerKarl Berry <karl@freefriends.org>2016-04-05 22:27:26 +0000
commitb56b320b5e2515160073fa1b469514002688fe11 (patch)
tree965a7100c5e45fca8ec803d22b8b6ce14fca4633 /Master/tlpkg/tlperl/lib/overload.pm
parentd26c206452d2e285c3bbf949f34011e4a55fd8f9 (diff)
tlperl 5.22.1 from siep
git-svn-id: svn://tug.org/texlive/trunk@40252 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlperl/lib/overload.pm')
-rw-r--r--Master/tlpkg/tlperl/lib/overload.pm42
1 files changed, 26 insertions, 16 deletions
diff --git a/Master/tlpkg/tlperl/lib/overload.pm b/Master/tlpkg/tlperl/lib/overload.pm
index 51801d643d9..4a1912c2366 100644
--- a/Master/tlpkg/tlperl/lib/overload.pm
+++ b/Master/tlpkg/tlperl/lib/overload.pm
@@ -1,6 +1,6 @@
package overload;
-our $VERSION = '1.22';
+our $VERSION = '1.26';
%ops = (
with_assign => "+ - * / % ** << >> x .",
@@ -8,8 +8,8 @@ our $VERSION = '1.22';
num_comparison => "< <= > >= == !=",
'3way_comparison' => "<=> cmp",
str_comparison => "lt le gt ge eq ne",
- binary => '& &= | |= ^ ^=',
- unary => "neg ! ~",
+ binary => '& &= | |= ^ ^= &. &.= |. |.= ^. ^.=',
+ unary => "neg ! ~ ~.",
mutators => '++ --',
func => "atan2 cos sin exp abs log sqrt int",
conversion => 'bool "" 0+ qr',
@@ -30,7 +30,7 @@ sub nil {}
sub OVERLOAD {
$package = shift;
my %arg = @_;
- my ($sub, $fb);
+ my $sub;
*{$package . "::(("} = \&nil; # Make it findable via fetchmethod.
for (keys %arg) {
if ($_ eq 'fallback') {
@@ -81,7 +81,7 @@ sub ov_method {
return undef unless $globref;
my $sub = \&{*$globref};
no overloading;
- return $sub if !ref $sub or $sub != \&nil;
+ return $sub if $sub != \&nil;
return shift->can($ {*$globref});
}
@@ -252,7 +252,9 @@ illustrates the calling conventions:
# * may recurse once - see table below
Three arguments are passed to all subroutines specified in the
-C<use overload> directive (with one exception - see L</nomethod>).
+C<use overload> directive (with exceptions - see below, particularly
+L</nomethod>).
+
The first of these is the operand providing the overloaded
operator implementation -
in this case, the object whose C<minus()> method is being called.
@@ -310,6 +312,12 @@ An appropriate implementation of C<--> might look like
# ...
sub decr { --${$_[0]}; }
+If the experimental "bitwise" feature is enabled (see L<feature>), a fifth
+TRUE argument is passed to subroutines handling C<&>, C<|>, C<^> and C<~>.
+This indicates that the caller is expecting numeric behaviour. The fourth
+argument will be C<undef>, as that position (C<$_[3]>) is reserved for use
+by L</nomethod>.
+
=head3 Mathemagic, Mutators, and Copy Constructors
The term 'mathemagic' describes the overloaded implementation
@@ -361,8 +369,8 @@ hash C<%overload::ops>:
num_comparison => '< <= > >= == !=',
'3way_comparison'=> '<=> cmp',
str_comparison => 'lt le gt ge eq ne',
- binary => '& &= | |= ^ ^=',
- unary => 'neg ! ~',
+ binary => '& &= | |= ^ ^= &. &.= |. |.= ^. ^.=',
+ unary => 'neg ! ~ ~.',
mutators => '++ --',
func => 'atan2 cos sin exp abs log sqrt int',
conversion => 'bool "" 0+ qr',
@@ -375,6 +383,7 @@ hash C<%overload::ops>:
Most of the overloadable operators map one-to-one to these keys.
Exceptions, including additional overloadable operations not
apparent from this hash, are included in the notes which follow.
+This list is subject to growth over time.
A warning is issued if an attempt is made to register an operator not found
above.
@@ -407,7 +416,7 @@ evaluating an expression.
=item * I<Assignments>
+= -= *= /= %= **= <<= >>= x= .=
- &= |= ^=
+ &= |= ^= &.= |.= ^.=
Simple assignment is not overloadable (the C<'='> key is used
for the L<Copy Constructor>).
@@ -437,7 +446,7 @@ even if C<$a> is a scalar.
=item * I<Non-mutators with a mutator variant>
+ - * / % ** << >> x .
- & | ^
+ & | ^ &. |. ^.
As described L<above|"Calling Conventions and Magic Autogeneration">,
Perl may call methods for operators like C<+> and C<&> in the course
@@ -650,9 +659,9 @@ to C<'-='> and C<'--'> above:
And other assignment variations are analogous to
C<'+='> and C<'-='> (and similar to C<'.='> and C<'x='> above):
- operator || *= /= %= **= <<= >>= &= ^= |=
- -------------------||--------------------------------
- autogenerated from || * / % ** << >> & ^ |
+ operator || *= /= %= **= <<= >>= &= ^= |= &.= ^.= |.=
+ -------------------||-------------------------------------------
+ autogenerated from || * / % ** << >> & ^ | &. ^. |.
Note also that the copy constructor (key C<'='>) may be
autogenerated, but only for objects based on scalars.
@@ -668,7 +677,7 @@ expects. The minimal set is:
+ - * / % ** << >> x
<=> cmp
- & | ^ ~
+ & | ^ ~ &. |. ^. ~.
atan2 cos sin exp log sqrt int
"" 0+ bool
~~
@@ -686,7 +695,8 @@ The specified function will be passed four parameters.
The first three arguments coincide with those that would have been
passed to the corresponding method if it had been defined.
The fourth argument is the C<use overload> key for that missing
-method.
+method. If the experimental "bitwise" feature is enabled (see L<feature>),
+a fifth TRUE argument is passed to subroutines handling C<&>, C<|>, C<^> and C<~> to indicate that the caller is expecting numeric behaviour.
For example, if C<$a> is an object blessed into a package declaring
@@ -1054,7 +1064,7 @@ the stashes, which are rarely used directly, thus should not slow down
Perl.)
If a package uses overload, it carries a special flag. This flag is also
-set when new function are defined or @ISA is modified. There will be a
+set when new functions are defined or @ISA is modified. There will be a
slight speed penalty on the very first operation thereafter that supports
overloading, while the overload tables are updated. If there is no
overloading present, the flag is turned off. Thus the only speed penalty