in reply to Re^8: Puzzled by value of $overload::ops{binary}
in thread Puzzled by value of $overload::ops{binary}
Note that it's specifically stating that it's "permitted" (but not mandatory) "to change the value of its operand ".The subroutine for the assignment variant of an operator is required only to return the result of the operation. It is permitted to change the value of its operand (this is safe be +cause Perl calls the copy constructor first), but this is optional +since Perl assigns the returned value to the left-hand operand anyw +ay.
which I manually altered to:'+=' => sub { $_[0] -> badd($_[1]); },
I then get:'+=' => sub { $_[0] -> badd($_[1]); 42 },
In that pure perl environment it's clearly the returned result, not the result of the inplace addition, that's being seen.D:\>perl -MDevel::Peek -MMath::BigFloat -le "$x = Math::BigFloat->new( +20); $x += 100; print $x; Dump $x;" 42 SV = PVIV(0x1bc99137430) at 0x1bc9913a450 REFCNT = 1 FLAGS = (IOK,pIOK,pPOK) IV = 42 PV = 0x1bc9b44fbe0 "42"\0 CUR = 2 LEN = 16
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^10: Puzzled by value of $overload::ops{binary}
by etj (Priest) on Jun 27, 2024 at 10:01 UTC | |
by syphilis (Archbishop) on Jun 27, 2024 at 10:42 UTC | |
by etj (Priest) on Jun 27, 2024 at 13:36 UTC | |
by syphilis (Archbishop) on Jun 28, 2024 at 11:41 UTC | |
by etj (Priest) on Jun 30, 2024 at 11:00 UTC | |
|