our $VERSION = '1.04';
-$overload::hint_bits = 0x20000; # HINT_LOCALIZE_HH
-
sub nil {}
sub OVERLOAD {
num_comparison => "< <= > >= == !=",
'3way_comparison'=> "<=> cmp",
str_comparison => "lt le gt ge eq ne",
- binary => "& | ^",
+ binary => '& &= | |= ^ ^=',
unary => "neg ! ~",
mutators => '++ --',
func => "atan2 cos sin exp abs log sqrt int",
}
else {
$^H{$_[0]} = $_[1];
- $^H |= $constants{$_[0]} | $overload::hint_bits;
+ $^H |= $constants{$_[0]};
}
shift, shift;
}
=item * I<Bit operations>
- "&", "^", "|", "neg", "!", "~",
+ "&", "&=", "^", "^=", "|", "|=", "neg", "!", "~",
C<neg> stands for unary minus. If the method for C<neg> is not
specified, it can be autogenerated using the method for
subtraction. If the method for C<!> is not specified, it can be
autogenerated using the methods for C<bool>, or C<"">, or C<0+>.
+The same remarks in L<"Arithmetic operations"> about
+assignment-variants and autogeneration apply for
+bit operations C<"&">, C<"^">, and C<"|"> as well.
+
=item * I<Increment and decrement>
"++", "--",
num_comparison => '< <= > >= == !=',
'3way_comparison'=> '<=> cmp',
str_comparison => 'lt le gt ge eq ne',
- binary => '& | ^',
+ binary => '& &= | |= ^ ^=',
unary => 'neg ! ~',
mutators => '++ --',
func => 'atan2 cos sin exp abs log sqrt',
operation is not found. Three different cases are possible depending on
the value of C<"fallback">:
-=head2 Smart Match
-
-The key C<"~~"> allows you to override the smart matching used by
-the switch construct. See L<feature>.
-
=over 16
=item * C<undef>
B<Note.> C<"fallback"> inheritance via @ISA is not carved in stone
yet, see L<"Inheritance and overloading">.
+=head2 Smart Match
+
+The key C<"~~"> allows you to override the smart matching used by
+the switch construct. See L<feature>.
+
=head2 Copy Constructor
The value for C<"="> is a reference to a function with three
Since some operations can be automatically generated from others, there is
a minimal set of operations that need to be overloaded in order to have
-the complete set of overloaded operations at one's disposal. This minimal
-set is:
+the complete set of overloaded operations at one's disposal.
+Of course, the autogenerated operations may not do exactly what the user
+expects. See L<MAGIC AUTOGENERATION> above. The minimal set is:
+ - * / % ** << >> x
<=> cmp
atan2 cos sin exp log sqrt int
Additionally, you need to define at least one of string, boolean or
-numeric conversions. The string conversion can also be used to
-emulate concatenation, so we'll assume string conversion is defined.
-It usually makes sense to explicitly overload all conversion
-operations.
+numeric conversions because any one can be used to emulate the others.
+The string conversion can also be used to emulate concatenation.
=head1 Losing overloading
Note that while we obtained this value using a nice little script,
there is no simple way to I<use> this value. In fact this value may
-be inspected in debugger (see L<perldebug>), but ony if
+be inspected in debugger (see L<perldebug>), but only if
C<bareStringify> B<O>ption is set, and not via C<p> command.
If one attempts to print this value, then the overloaded operator