in reply to Re^2: Puzzled by value of $overload::ops{binary}
in thread Puzzled by value of $overload::ops{binary}
Modifying the generated code for += to this:$ret .= pp_line_numbers(__LINE__, <<EOF) if $mutator; BEGIN { # in1, in2, out, swap if true \$OVERLOADS{'$op='} = sub { PDL::$name(\$_[0]->inplace, \$_[1]); \$_[0 +] }; } EOF
and running it like this:#line 192 "ops.pd" BEGIN { # in1, in2, out, swap if true $OVERLOADS{'+='} = sub { use Carp; use Test::More; diag "RUN ", Test::More::explain \@_; PDL::plus($_[0]->inplace, $_[1]); $_[0] }; }
gives:$ perl -MPDL -e '$p=pdl(1); $p+=2'
so your XS function should work. Did you make an overload for +=?# RUN [ # bless( do{\(my $o = '94749946365136')}, 'PDL' ), # 2, # undef # ]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Puzzled by value of $overload::ops{binary}
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 | |
by etj (Priest) on Jun 26, 2024 at 22:08 UTC | |
|