| [3181] | 1 | package overload;
|
|---|
| 2 |
|
|---|
| 3 | our $VERSION = '1.04';
|
|---|
| 4 |
|
|---|
| 5 | $overload::hint_bits = 0x20000; # HINT_LOCALIZE_HH
|
|---|
| 6 |
|
|---|
| 7 | sub nil {}
|
|---|
| 8 |
|
|---|
| 9 | sub OVERLOAD {
|
|---|
| 10 | $package = shift;
|
|---|
| 11 | my %arg = @_;
|
|---|
| 12 | my ($sub, $fb);
|
|---|
| 13 | $ {$package . "::OVERLOAD"}{dummy}++; # Register with magic by touching.
|
|---|
| 14 | *{$package . "::()"} = \&nil; # Make it findable via fetchmethod.
|
|---|
| 15 | for (keys %arg) {
|
|---|
| 16 | if ($_ eq 'fallback') {
|
|---|
| 17 | $fb = $arg{$_};
|
|---|
| 18 | } else {
|
|---|
| 19 | $sub = $arg{$_};
|
|---|
| 20 | if (not ref $sub and $sub !~ /::/) {
|
|---|
| 21 | $ {$package . "::(" . $_} = $sub;
|
|---|
| 22 | $sub = \&nil;
|
|---|
| 23 | }
|
|---|
| 24 | #print STDERR "Setting `$ {'package'}::\cO$_' to \\&`$sub'.\n";
|
|---|
| 25 | *{$package . "::(" . $_} = \&{ $sub };
|
|---|
| 26 | }
|
|---|
| 27 | }
|
|---|
| 28 | ${$package . "::()"} = $fb; # Make it findable too (fallback only).
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | sub import {
|
|---|
| 32 | $package = (caller())[0];
|
|---|
| 33 | # *{$package . "::OVERLOAD"} = \&OVERLOAD;
|
|---|
| 34 | shift;
|
|---|
| 35 | $package->overload::OVERLOAD(@_);
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | sub unimport {
|
|---|
| 39 | $package = (caller())[0];
|
|---|
| 40 | ${$package . "::OVERLOAD"}{dummy}++; # Upgrade the table
|
|---|
| 41 | shift;
|
|---|
| 42 | for (@_) {
|
|---|
| 43 | if ($_ eq 'fallback') {
|
|---|
| 44 | undef $ {$package . "::()"};
|
|---|
| 45 | } else {
|
|---|
| 46 | delete $ {$package . "::"}{"(" . $_};
|
|---|
| 47 | }
|
|---|
| 48 | }
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | sub Overloaded {
|
|---|
| 52 | my $package = shift;
|
|---|
| 53 | $package = ref $package if ref $package;
|
|---|
| 54 | $package->can('()');
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | sub ov_method {
|
|---|
| 58 | my $globref = shift;
|
|---|
| 59 | return undef unless $globref;
|
|---|
| 60 | my $sub = \&{*$globref};
|
|---|
| 61 | return $sub if $sub ne \&nil;
|
|---|
| 62 | return shift->can($ {*$globref});
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | sub OverloadedStringify {
|
|---|
| 66 | my $package = shift;
|
|---|
| 67 | $package = ref $package if ref $package;
|
|---|
| 68 | #$package->can('(""')
|
|---|
| 69 | ov_method mycan($package, '(""'), $package
|
|---|
| 70 | or ov_method mycan($package, '(0+'), $package
|
|---|
| 71 | or ov_method mycan($package, '(bool'), $package
|
|---|
| 72 | or ov_method mycan($package, '(nomethod'), $package;
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | sub Method {
|
|---|
| 76 | my $package = shift;
|
|---|
| 77 | $package = ref $package if ref $package;
|
|---|
| 78 | #my $meth = $package->can('(' . shift);
|
|---|
| 79 | ov_method mycan($package, '(' . shift), $package;
|
|---|
| 80 | #return $meth if $meth ne \&nil;
|
|---|
| 81 | #return $ {*{$meth}};
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|
| 84 | sub AddrRef {
|
|---|
| 85 | my $package = ref $_[0];
|
|---|
| 86 | return "$_[0]" unless $package;
|
|---|
| 87 |
|
|---|
| 88 | require Scalar::Util;
|
|---|
| 89 | my $class = Scalar::Util::blessed($_[0]);
|
|---|
| 90 | my $class_prefix = defined($class) ? "$class=" : "";
|
|---|
| 91 | my $type = Scalar::Util::reftype($_[0]);
|
|---|
| 92 | my $addr = Scalar::Util::refaddr($_[0]);
|
|---|
| 93 | return sprintf("$class_prefix$type(0x%x)", $addr);
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | *StrVal = *AddrRef;
|
|---|
| 97 |
|
|---|
| 98 | sub mycan { # Real can would leave stubs.
|
|---|
| 99 | my ($package, $meth) = @_;
|
|---|
| 100 | return \*{$package . "::$meth"} if defined &{$package . "::$meth"};
|
|---|
| 101 | my $p;
|
|---|
| 102 | foreach $p (@{$package . "::ISA"}) {
|
|---|
| 103 | my $out = mycan($p, $meth);
|
|---|
| 104 | return $out if $out;
|
|---|
| 105 | }
|
|---|
| 106 | return undef;
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | %constants = (
|
|---|
| 110 | 'integer' => 0x1000, # HINT_NEW_INTEGER
|
|---|
| 111 | 'float' => 0x2000, # HINT_NEW_FLOAT
|
|---|
| 112 | 'binary' => 0x4000, # HINT_NEW_BINARY
|
|---|
| 113 | 'q' => 0x8000, # HINT_NEW_STRING
|
|---|
| 114 | 'qr' => 0x10000, # HINT_NEW_RE
|
|---|
| 115 | );
|
|---|
| 116 |
|
|---|
| 117 | %ops = ( with_assign => "+ - * / % ** << >> x .",
|
|---|
| 118 | assign => "+= -= *= /= %= **= <<= >>= x= .=",
|
|---|
| 119 | num_comparison => "< <= > >= == !=",
|
|---|
| 120 | '3way_comparison'=> "<=> cmp",
|
|---|
| 121 | str_comparison => "lt le gt ge eq ne",
|
|---|
| 122 | binary => "& | ^",
|
|---|
| 123 | unary => "neg ! ~",
|
|---|
| 124 | mutators => '++ --',
|
|---|
| 125 | func => "atan2 cos sin exp abs log sqrt int",
|
|---|
| 126 | conversion => 'bool "" 0+',
|
|---|
| 127 | iterators => '<>',
|
|---|
| 128 | dereferencing => '${} @{} %{} &{} *{}',
|
|---|
| 129 | special => 'nomethod fallback =');
|
|---|
| 130 |
|
|---|
| 131 | use warnings::register;
|
|---|
| 132 | sub constant {
|
|---|
| 133 | # Arguments: what, sub
|
|---|
| 134 | while (@_) {
|
|---|
| 135 | if (@_ == 1) {
|
|---|
| 136 | warnings::warnif ("Odd number of arguments for overload::constant");
|
|---|
| 137 | last;
|
|---|
| 138 | }
|
|---|
| 139 | elsif (!exists $constants {$_ [0]}) {
|
|---|
| 140 | warnings::warnif ("`$_[0]' is not an overloadable type");
|
|---|
| 141 | }
|
|---|
| 142 | elsif (!ref $_ [1] || "$_[1]" !~ /CODE\(0x[\da-f]+\)$/) {
|
|---|
| 143 | # Can't use C<ref $_[1] eq "CODE"> above as code references can be
|
|---|
| 144 | # blessed, and C<ref> would return the package the ref is blessed into.
|
|---|
| 145 | if (warnings::enabled) {
|
|---|
| 146 | $_ [1] = "undef" unless defined $_ [1];
|
|---|
| 147 | warnings::warn ("`$_[1]' is not a code reference");
|
|---|
| 148 | }
|
|---|
| 149 | }
|
|---|
| 150 | else {
|
|---|
| 151 | $^H{$_[0]} = $_[1];
|
|---|
| 152 | $^H |= $constants{$_[0]} | $overload::hint_bits;
|
|---|
| 153 | }
|
|---|
| 154 | shift, shift;
|
|---|
| 155 | }
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | sub remove_constant {
|
|---|
| 159 | # Arguments: what, sub
|
|---|
| 160 | while (@_) {
|
|---|
| 161 | delete $^H{$_[0]};
|
|---|
| 162 | $^H &= ~ $constants{$_[0]};
|
|---|
| 163 | shift, shift;
|
|---|
| 164 | }
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| 167 | 1;
|
|---|
| 168 |
|
|---|
| 169 | __END__
|
|---|
| 170 |
|
|---|
| 171 | =head1 NAME
|
|---|
| 172 |
|
|---|
| 173 | overload - Package for overloading Perl operations
|
|---|
| 174 |
|
|---|
| 175 | =head1 SYNOPSIS
|
|---|
| 176 |
|
|---|
| 177 | package SomeThing;
|
|---|
| 178 |
|
|---|
| 179 | use overload
|
|---|
| 180 | '+' => \&myadd,
|
|---|
| 181 | '-' => \&mysub;
|
|---|
| 182 | # etc
|
|---|
| 183 | ...
|
|---|
| 184 |
|
|---|
| 185 | package main;
|
|---|
| 186 | $a = new SomeThing 57;
|
|---|
| 187 | $b=5+$a;
|
|---|
| 188 | ...
|
|---|
| 189 | if (overload::Overloaded $b) {...}
|
|---|
| 190 | ...
|
|---|
| 191 | $strval = overload::StrVal $b;
|
|---|
| 192 |
|
|---|
| 193 | =head1 DESCRIPTION
|
|---|
| 194 |
|
|---|
| 195 | =head2 Declaration of overloaded functions
|
|---|
| 196 |
|
|---|
| 197 | The compilation directive
|
|---|
| 198 |
|
|---|
| 199 | package Number;
|
|---|
| 200 | use overload
|
|---|
| 201 | "+" => \&add,
|
|---|
| 202 | "*=" => "muas";
|
|---|
| 203 |
|
|---|
| 204 | declares function Number::add() for addition, and method muas() in
|
|---|
| 205 | the "class" C<Number> (or one of its base classes)
|
|---|
| 206 | for the assignment form C<*=> of multiplication.
|
|---|
| 207 |
|
|---|
| 208 | Arguments of this directive come in (key, value) pairs. Legal values
|
|---|
| 209 | are values legal inside a C<&{ ... }> call, so the name of a
|
|---|
| 210 | subroutine, a reference to a subroutine, or an anonymous subroutine
|
|---|
| 211 | will all work. Note that values specified as strings are
|
|---|
| 212 | interpreted as methods, not subroutines. Legal keys are listed below.
|
|---|
| 213 |
|
|---|
| 214 | The subroutine C<add> will be called to execute C<$a+$b> if $a
|
|---|
| 215 | is a reference to an object blessed into the package C<Number>, or if $a is
|
|---|
| 216 | not an object from a package with defined mathemagic addition, but $b is a
|
|---|
| 217 | reference to a C<Number>. It can also be called in other situations, like
|
|---|
| 218 | C<$a+=7>, or C<$a++>. See L<MAGIC AUTOGENERATION>. (Mathemagical
|
|---|
| 219 | methods refer to methods triggered by an overloaded mathematical
|
|---|
| 220 | operator.)
|
|---|
| 221 |
|
|---|
| 222 | Since overloading respects inheritance via the @ISA hierarchy, the
|
|---|
| 223 | above declaration would also trigger overloading of C<+> and C<*=> in
|
|---|
| 224 | all the packages which inherit from C<Number>.
|
|---|
| 225 |
|
|---|
| 226 | =head2 Calling Conventions for Binary Operations
|
|---|
| 227 |
|
|---|
| 228 | The functions specified in the C<use overload ...> directive are called
|
|---|
| 229 | with three (in one particular case with four, see L<Last Resort>)
|
|---|
| 230 | arguments. If the corresponding operation is binary, then the first
|
|---|
| 231 | two arguments are the two arguments of the operation. However, due to
|
|---|
| 232 | general object calling conventions, the first argument should always be
|
|---|
| 233 | an object in the package, so in the situation of C<7+$a>, the
|
|---|
| 234 | order of the arguments is interchanged. It probably does not matter
|
|---|
| 235 | when implementing the addition method, but whether the arguments
|
|---|
| 236 | are reversed is vital to the subtraction method. The method can
|
|---|
| 237 | query this information by examining the third argument, which can take
|
|---|
| 238 | three different values:
|
|---|
| 239 |
|
|---|
| 240 | =over 7
|
|---|
| 241 |
|
|---|
| 242 | =item FALSE
|
|---|
| 243 |
|
|---|
| 244 | the order of arguments is as in the current operation.
|
|---|
| 245 |
|
|---|
| 246 | =item TRUE
|
|---|
| 247 |
|
|---|
| 248 | the arguments are reversed.
|
|---|
| 249 |
|
|---|
| 250 | =item C<undef>
|
|---|
| 251 |
|
|---|
| 252 | the current operation is an assignment variant (as in
|
|---|
| 253 | C<$a+=7>), but the usual function is called instead. This additional
|
|---|
| 254 | information can be used to generate some optimizations. Compare
|
|---|
| 255 | L<Calling Conventions for Mutators>.
|
|---|
| 256 |
|
|---|
| 257 | =back
|
|---|
| 258 |
|
|---|
| 259 | =head2 Calling Conventions for Unary Operations
|
|---|
| 260 |
|
|---|
| 261 | Unary operation are considered binary operations with the second
|
|---|
| 262 | argument being C<undef>. Thus the functions that overloads C<{"++"}>
|
|---|
| 263 | is called with arguments C<($a,undef,'')> when $a++ is executed.
|
|---|
| 264 |
|
|---|
| 265 | =head2 Calling Conventions for Mutators
|
|---|
| 266 |
|
|---|
| 267 | Two types of mutators have different calling conventions:
|
|---|
| 268 |
|
|---|
| 269 | =over
|
|---|
| 270 |
|
|---|
| 271 | =item C<++> and C<-->
|
|---|
| 272 |
|
|---|
| 273 | The routines which implement these operators are expected to actually
|
|---|
| 274 | I<mutate> their arguments. So, assuming that $obj is a reference to a
|
|---|
| 275 | number,
|
|---|
| 276 |
|
|---|
| 277 | sub incr { my $n = $ {$_[0]}; ++$n; $_[0] = bless \$n}
|
|---|
| 278 |
|
|---|
| 279 | is an appropriate implementation of overloaded C<++>. Note that
|
|---|
| 280 |
|
|---|
| 281 | sub incr { ++$ {$_[0]} ; shift }
|
|---|
| 282 |
|
|---|
| 283 | is OK if used with preincrement and with postincrement. (In the case
|
|---|
| 284 | of postincrement a copying will be performed, see L<Copy Constructor>.)
|
|---|
| 285 |
|
|---|
| 286 | =item C<x=> and other assignment versions
|
|---|
| 287 |
|
|---|
| 288 | There is nothing special about these methods. They may change the
|
|---|
| 289 | value of their arguments, and may leave it as is. The result is going
|
|---|
| 290 | to be assigned to the value in the left-hand-side if different from
|
|---|
| 291 | this value.
|
|---|
| 292 |
|
|---|
| 293 | This allows for the same method to be used as overloaded C<+=> and
|
|---|
| 294 | C<+>. Note that this is I<allowed>, but not recommended, since by the
|
|---|
| 295 | semantic of L<"Fallback"> Perl will call the method for C<+> anyway,
|
|---|
| 296 | if C<+=> is not overloaded.
|
|---|
| 297 |
|
|---|
| 298 | =back
|
|---|
| 299 |
|
|---|
| 300 | B<Warning.> Due to the presence of assignment versions of operations,
|
|---|
| 301 | routines which may be called in assignment context may create
|
|---|
| 302 | self-referential structures. Currently Perl will not free self-referential
|
|---|
| 303 | structures until cycles are C<explicitly> broken. You may get problems
|
|---|
| 304 | when traversing your structures too.
|
|---|
| 305 |
|
|---|
| 306 | Say,
|
|---|
| 307 |
|
|---|
| 308 | use overload '+' => sub { bless [ \$_[0], \$_[1] ] };
|
|---|
| 309 |
|
|---|
| 310 | is asking for trouble, since for code C<$obj += $foo> the subroutine
|
|---|
| 311 | is called as C<$obj = add($obj, $foo, undef)>, or C<$obj = [\$obj,
|
|---|
| 312 | \$foo]>. If using such a subroutine is an important optimization, one
|
|---|
| 313 | can overload C<+=> explicitly by a non-"optimized" version, or switch
|
|---|
| 314 | to non-optimized version if C<not defined $_[2]> (see
|
|---|
| 315 | L<Calling Conventions for Binary Operations>).
|
|---|
| 316 |
|
|---|
| 317 | Even if no I<explicit> assignment-variants of operators are present in
|
|---|
| 318 | the script, they may be generated by the optimizer. Say, C<",$obj,"> or
|
|---|
| 319 | C<',' . $obj . ','> may be both optimized to
|
|---|
| 320 |
|
|---|
| 321 | my $tmp = ',' . $obj; $tmp .= ',';
|
|---|
| 322 |
|
|---|
| 323 | =head2 Overloadable Operations
|
|---|
| 324 |
|
|---|
| 325 | The following symbols can be specified in C<use overload> directive:
|
|---|
| 326 |
|
|---|
| 327 | =over 5
|
|---|
| 328 |
|
|---|
| 329 | =item * I<Arithmetic operations>
|
|---|
| 330 |
|
|---|
| 331 | "+", "+=", "-", "-=", "*", "*=", "/", "/=", "%", "%=",
|
|---|
| 332 | "**", "**=", "<<", "<<=", ">>", ">>=", "x", "x=", ".", ".=",
|
|---|
| 333 |
|
|---|
| 334 | For these operations a substituted non-assignment variant can be called if
|
|---|
| 335 | the assignment variant is not available. Methods for operations C<+>,
|
|---|
| 336 | C<->, C<+=>, and C<-=> can be called to automatically generate
|
|---|
| 337 | increment and decrement methods. The operation C<-> can be used to
|
|---|
| 338 | autogenerate missing methods for unary minus or C<abs>.
|
|---|
| 339 |
|
|---|
| 340 | See L<"MAGIC AUTOGENERATION">, L<"Calling Conventions for Mutators"> and
|
|---|
| 341 | L<"Calling Conventions for Binary Operations">) for details of these
|
|---|
| 342 | substitutions.
|
|---|
| 343 |
|
|---|
| 344 | =item * I<Comparison operations>
|
|---|
| 345 |
|
|---|
| 346 | "<", "<=", ">", ">=", "==", "!=", "<=>",
|
|---|
| 347 | "lt", "le", "gt", "ge", "eq", "ne", "cmp",
|
|---|
| 348 |
|
|---|
| 349 | If the corresponding "spaceship" variant is available, it can be
|
|---|
| 350 | used to substitute for the missing operation. During C<sort>ing
|
|---|
| 351 | arrays, C<cmp> is used to compare values subject to C<use overload>.
|
|---|
| 352 |
|
|---|
| 353 | =item * I<Bit operations>
|
|---|
| 354 |
|
|---|
| 355 | "&", "^", "|", "neg", "!", "~",
|
|---|
| 356 |
|
|---|
| 357 | C<neg> stands for unary minus. If the method for C<neg> is not
|
|---|
| 358 | specified, it can be autogenerated using the method for
|
|---|
| 359 | subtraction. If the method for C<!> is not specified, it can be
|
|---|
| 360 | autogenerated using the methods for C<bool>, or C<"">, or C<0+>.
|
|---|
| 361 |
|
|---|
| 362 | =item * I<Increment and decrement>
|
|---|
| 363 |
|
|---|
| 364 | "++", "--",
|
|---|
| 365 |
|
|---|
| 366 | If undefined, addition and subtraction methods can be
|
|---|
| 367 | used instead. These operations are called both in prefix and
|
|---|
| 368 | postfix form.
|
|---|
| 369 |
|
|---|
| 370 | =item * I<Transcendental functions>
|
|---|
| 371 |
|
|---|
| 372 | "atan2", "cos", "sin", "exp", "abs", "log", "sqrt", "int"
|
|---|
| 373 |
|
|---|
| 374 | If C<abs> is unavailable, it can be autogenerated using methods
|
|---|
| 375 | for "E<lt>" or "E<lt>=E<gt>" combined with either unary minus or subtraction.
|
|---|
| 376 |
|
|---|
| 377 | Note that traditionally the Perl function L<int> rounds to 0, thus for
|
|---|
| 378 | floating-point-like types one should follow the same semantic. If
|
|---|
| 379 | C<int> is unavailable, it can be autogenerated using the overloading of
|
|---|
| 380 | C<0+>.
|
|---|
| 381 |
|
|---|
| 382 | =item * I<Boolean, string and numeric conversion>
|
|---|
| 383 |
|
|---|
| 384 | 'bool', '""', '0+',
|
|---|
| 385 |
|
|---|
| 386 | If one or two of these operations are not overloaded, the remaining ones can
|
|---|
| 387 | be used instead. C<bool> is used in the flow control operators
|
|---|
| 388 | (like C<while>) and for the ternary C<?:> operation. These functions can
|
|---|
| 389 | return any arbitrary Perl value. If the corresponding operation for this value
|
|---|
| 390 | is overloaded too, that operation will be called again with this value.
|
|---|
| 391 |
|
|---|
| 392 | As a special case if the overload returns the object itself then it will
|
|---|
| 393 | be used directly. An overloaded conversion returning the object is
|
|---|
| 394 | probably a bug, because you're likely to get something that looks like
|
|---|
| 395 | C<YourPackage=HASH(0x8172b34)>.
|
|---|
| 396 |
|
|---|
| 397 | =item * I<Iteration>
|
|---|
| 398 |
|
|---|
| 399 | "<>"
|
|---|
| 400 |
|
|---|
| 401 | If not overloaded, the argument will be converted to a filehandle or
|
|---|
| 402 | glob (which may require a stringification). The same overloading
|
|---|
| 403 | happens both for the I<read-filehandle> syntax C<E<lt>$varE<gt>> and
|
|---|
| 404 | I<globbing> syntax C<E<lt>${var}E<gt>>.
|
|---|
| 405 |
|
|---|
| 406 | B<BUGS> Even in list context, the iterator is currently called only
|
|---|
| 407 | once and with scalar context.
|
|---|
| 408 |
|
|---|
| 409 | =item * I<Dereferencing>
|
|---|
| 410 |
|
|---|
| 411 | '${}', '@{}', '%{}', '&{}', '*{}'.
|
|---|
| 412 |
|
|---|
| 413 | If not overloaded, the argument will be dereferenced I<as is>, thus
|
|---|
| 414 | should be of correct type. These functions should return a reference
|
|---|
| 415 | of correct type, or another object with overloaded dereferencing.
|
|---|
| 416 |
|
|---|
| 417 | As a special case if the overload returns the object itself then it
|
|---|
| 418 | will be used directly (provided it is the correct type).
|
|---|
| 419 |
|
|---|
| 420 | The dereference operators must be specified explicitly they will not be passed to
|
|---|
| 421 | "nomethod".
|
|---|
| 422 |
|
|---|
| 423 | =item * I<Special>
|
|---|
| 424 |
|
|---|
| 425 | "nomethod", "fallback", "=",
|
|---|
| 426 |
|
|---|
| 427 | see L<SPECIAL SYMBOLS FOR C<use overload>>.
|
|---|
| 428 |
|
|---|
| 429 | =back
|
|---|
| 430 |
|
|---|
| 431 | See L<"Fallback"> for an explanation of when a missing method can be
|
|---|
| 432 | autogenerated.
|
|---|
| 433 |
|
|---|
| 434 | A computer-readable form of the above table is available in the hash
|
|---|
| 435 | %overload::ops, with values being space-separated lists of names:
|
|---|
| 436 |
|
|---|
| 437 | with_assign => '+ - * / % ** << >> x .',
|
|---|
| 438 | assign => '+= -= *= /= %= **= <<= >>= x= .=',
|
|---|
| 439 | num_comparison => '< <= > >= == !=',
|
|---|
| 440 | '3way_comparison'=> '<=> cmp',
|
|---|
| 441 | str_comparison => 'lt le gt ge eq ne',
|
|---|
| 442 | binary => '& | ^',
|
|---|
| 443 | unary => 'neg ! ~',
|
|---|
| 444 | mutators => '++ --',
|
|---|
| 445 | func => 'atan2 cos sin exp abs log sqrt',
|
|---|
| 446 | conversion => 'bool "" 0+',
|
|---|
| 447 | iterators => '<>',
|
|---|
| 448 | dereferencing => '${} @{} %{} &{} *{}',
|
|---|
| 449 | special => 'nomethod fallback ='
|
|---|
| 450 |
|
|---|
| 451 | =head2 Inheritance and overloading
|
|---|
| 452 |
|
|---|
| 453 | Inheritance interacts with overloading in two ways.
|
|---|
| 454 |
|
|---|
| 455 | =over
|
|---|
| 456 |
|
|---|
| |
|---|