in reply to Re: Puzzled by value of $overload::ops{binary}
in thread Puzzled by value of $overload::ops{binary}
That always works perfectly well.void overload_inc($V * object, SV * second, SV * switch) { /* code that adds 1 to the value held by object */ }
That attempt (in overload_plus_eq), to modify the object in place always fails when called by the '+=' operator - and I have never been able to write that XSub such that it is successfully called via overloading of '+=', unless it returns a new object that overwrites the existing one.void overload_plus_eq(SV * object, SV * addon, SV * switch) { /*code that adds the value of addon to the value held by object */ }
Seems a bit odd .... but perhaps of little or no importance.D:\>perl -Mwarnings -Moverload -e "use overload 'fu' => sub {return 1} +;" overload arg 'fu' is invalid at -e line 1. D:\>perl -Mwarnings -Moverload -e "use overload '&.' => sub {return 1} +;" D:\>perl -Mwarnings -Moverload -e "use overload '&.=' => sub {return 1 +};" D:\>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Puzzled by value of $overload::ops{binary}
by etj (Priest) on Jun 25, 2024 at 12:11 UTC | |
by syphilis (Archbishop) on Jun 25, 2024 at 14:38 UTC | |
by syphilis (Archbishop) on Jun 26, 2024 at 02:10 UTC | |
by etj (Priest) on Jun 26, 2024 at 11:35 UTC | |
by syphilis (Archbishop) on Jun 26, 2024 at 14:28 UTC | |
|