This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fixes to compile Perl with g++ and DEBUGGING.
[perl5.git] / lib / overload.pm
index b189044..690be22 100644 (file)
@@ -1,8 +1,6 @@
 package overload;
 
-our $VERSION = '1.03';
-
-$overload::hint_bits = 0x20000; # HINT_LOCALIZE_HH
+our $VERSION = '1.04';
 
 sub nil {}
 
@@ -149,7 +147,7 @@ sub constant {
     }
     else {
         $^H{$_[0]} = $_[1];
-        $^H |= $constants{$_[0]} | $overload::hint_bits;
+        $^H |= $constants{$_[0]};
     }
     shift, shift;
   }
@@ -422,7 +420,7 @@ The dereference operators must be specified explicitly they will not be passed t
 
 =item * I<Special>
 
-    "nomethod", "fallback", "=",
+    "nomethod", "fallback", "=", "~~",
 
 see L<SPECIAL SYMBOLS FOR C<use overload>>.
 
@@ -542,6 +540,11 @@ C<"nomethod"> value, and if this is missing, raises an exception.
 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
@@ -663,6 +666,23 @@ value is a scalar and not a reference.
 
 =back
 
+=head1 Minimal set of overloaded operations
+
+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.
+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 because any one can be used to emulate the others.
+The string conversion can also be used to emulate concatenation.
+
 =head1 Losing overloading
 
 The restriction for the comparison operation is that even if, for example,
@@ -778,9 +798,6 @@ From these methods they may be called as
          overload::constant integer => sub {Math::BigInt->new(shift)};
        }
 
-B<BUGS> Currently overloaded-ness of constants does not propagate
-into C<eval '...'>.
-
 =head1 IMPLEMENTATION
 
 What follows is subject to change RSN.
@@ -1086,7 +1103,7 @@ The value of $side is
 
 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