X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Foverload.pm;h=c9044db0dc5a8bc353081caa5376b62b03901c66;hb=743a64fea7e861a13581486312a91a30a446b273;hp=2bbb639d9b5673c736ecc2feec9c2e58dc93b8d6;hpb=e7ea3e70155d0bea30720ba41eb6bb6742aac0d1;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/overload.pm b/lib/overload.pm index 2bbb639..c9044db 100644 --- a/lib/overload.pm +++ b/lib/overload.pm @@ -162,9 +162,9 @@ C<$a+=7>, or C<$a++>. See L. (Mathemagical methods refer to methods triggered by an overloaded mathematical operator.) -Since overloading respects @ISA hierarchy, in fact the above -declaration would also trigger overloading of C<+> and C<*=> in all -the packages which inherit from C. +Since overloading respects inheritance via the @ISA hierarchy, the +above declaration would also trigger overloading of C<+> and C<*=> in +all the packages which inherit from C. =head2 Calling Conventions for Binary Operations @@ -276,44 +276,44 @@ See L<"Fallback"> for an explanation of when a missing method can be autogenerat =head2 Inheritance and overloading -There are two ways how inheritance interacts with overloading. +Inheritance interacts with overloading in two ways. =over =item Strings as values of C directive -If the value of +If C in use overload key => value; -directive is a string, it is interpreted as a method name. +is a string, it is interpreted as a method name. =item Overloading of an operation is inherited by derived classes -If any of ancestors is overloaded, so is the derived class. The set of -overloaded methods is the union of overloaded methods of all the -ancestors. If some method is overloaded in several ancestor, then +Any class derived from an overloaded class is also overloaded. The +set of overloaded methods is the union of overloaded methods of all +the ancestors. If some method is overloaded in several ancestor, then which description will be used is decided by the usual inheritance -rules: +rules: -If C inherits from C and C (in this order), and C -overloads C<+> by C<\&D::plus_sub>, C overloads C<+> by -C<"plus_meth">, then the subroutine C will be called to -implement operation C<+> for an object in package C. +If C inherits from C and C (in this order), C overloads +C<+> with C<\&D::plus_sub>, and C overloads C<+> by C<"plus_meth">, +then the subroutine C will be called to implement +operation C<+> for an object in package C. =back -Note that since the value of C key is not a subroutine, its -inheritance is not governed by the above rules. Current implementation -is that the value of C in the first overloaded ancestor is -taken, but this may be subject to change. +Note that since the value of the C key is not a subroutine, +its inheritance is not governed by the above rules. In the current +implementation, the value of C in the first overloaded +ancestor is used, but this is accidental and subject to change. =head1 SPECIAL SYMBOLS FOR C Three keys are recognized by Perl that are not covered by the above description. -=head2 Last Resort +=head2 Last Resort C<"nomethod"> should be followed by a reference to a function of four parameters. If defined, it is called when the overloading mechanism @@ -546,14 +546,14 @@ If an object belongs to a package using overload, it carries a special flag. Thus the only speed penalty during arithmetic operations without overloading is the checking of this flag. -In fact, if C is not present, there is almost no overhead for -overloadable operations, so most programs should not suffer measurable -performance penalties. A considerable effort was made to minimize the overhead -when overload is used in some package, but -the arguments in question do not belong to packages using overload. When -in doubt, test your speed with C and without it. So far there -have been no reports of substantial speed degradation if Perl is compiled -with optimization turned on. +In fact, if C is not present, there is almost no overhead +for overloadable operations, so most programs should not suffer +measurable performance penalties. A considerable effort was made to +minimize the overhead when overload is used in some package, but the +arguments in question do not belong to packages using overload. When +in doubt, test your speed with C and without it. So far +there have been no reports of substantial speed degradation if Perl is +compiled with optimization turned on. There is no size penalty for data if overload is not used. The only size penalty if overload is used in some package is that I the @@ -588,9 +588,9 @@ function). =head1 BUGS -Because it is used for overloading, the per-package associative array -%OVERLOAD now has a special meaning in Perl. The symbol table is -filled with names looking like line-noise. +Because it is used for overloading, the per-package hash %OVERLOAD now +has a special meaning in Perl. The symbol table is filled with names +looking like line-noise. For the purpose of inheritance every overloaded package behaves as if C is present (possibly undefined). This may create