diff options
author | David Mitchell <davem@iabyn.com> | 2019-02-04 13:48:13 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2019-02-05 14:03:05 +0000 |
commit | 72876cce4ecc7d8756e00d284e32df0b943d0da9 (patch) | |
tree | eb2fbf4d5389c41ab464221a1089a9eb00429389 /pod/perlinterp.pod | |
parent | 35c1827fadfaf0a26b8d1373f06ee242ee79c111 (diff) | |
download | perl-72876cce4ecc7d8756e00d284e32df0b943d0da9.tar.gz |
Eliminate opASSIGN macro usage from core
This macro is defined as
(PL_op->op_flags & OPf_STACKED)
and indicates, for ops which support it, that the mutator-variant of the
op is present (e.g. $x += 1).
This macro was mainly used as an arg for the old-style overloading
macros (tryAMAGICbin()) which were eliminated several years ago.
This commit removes its vestigial usage, and instead tests OPf_STACKED
directly at each location, along with adding a comment about the
significance of the flag.
This removes one item of obfuscation from the overloading code.
There is one potentially functional change in this commit:
Perl_try_amagic_bin() was sometimes testing for OPf_STACKED without
first checking that it had been called with the AMGf_assign flag (which
indicates that this op supports a mutator variant). With this commit, it
now checks first, so this is theoretically a bug fix. In practice that
section of code was never reached without AMGf_assign always being set
anyway.
Diffstat (limited to 'pod/perlinterp.pod')
-rw-r--r-- | pod/perlinterp.pod | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/pod/perlinterp.pod b/pod/perlinterp.pod index 2d7073723e..b516badc8b 100644 --- a/pod/perlinterp.pod +++ b/pod/perlinterp.pod @@ -781,26 +781,27 @@ See L<perlguts/"Localizing changes"> for how to use the save stack. One thing you'll notice about the Perl source is that it's full of macros. Some have called the pervasive use of macros the hardest thing to understand, others find it adds to clarity. Let's take an example, -the code which implements the addition operator: +a stripped-down version the code which implements the addition operator: 1 PP(pp_add) 2 { - 3 dSP; dATARGET; tryAMAGICbin(add,opASSIGN); - 4 { - 5 dPOPTOPnnrl_ul; - 6 SETn( left + right ); - 7 RETURN; - 8 } - 9 } + 3 dSP; dATARGET; + 4 tryAMAGICbin_MG(add_amg, AMGf_assign|AMGf_numeric); + 5 { + 6 dPOPTOPnnrl_ul; + 7 SETn( left + right ); + 8 RETURN; + 9 } + 10 } Every line here (apart from the braces, of course) contains a macro. The first line sets up the function declaration as Perl expects for PP code; line 3 sets up variable declarations for the argument stack and -the target, the return value of the operation. Finally, it tries to see +the target, the return value of the operation. Line 4 tries to see if the addition operation is overloaded; if so, the appropriate subroutine is called. -Line 5 is another variable declaration - all variable declarations +Line 6 is another variable declaration - all variable declarations start with C<d> - which pops from the top of the argument stack two NVs (hence C<nn>) and puts them into the variables C<right> and C<left>, hence the C<rl>. These are the two operands to the addition operator. |