This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Change OA_DANGEROUS description in regen/opcode*
authorFather Chrysostomos <sprout@cpan.org>
Wed, 15 Oct 2014 04:56:25 +0000 (21:56 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Wed, 15 Oct 2014 05:01:46 +0000 (22:01 -0700)
‘Has side effects’ can be misleading.  The OA_DANGEROUS flag is only
used by the common-vars search that checks to see whether it is possi-
ble to skip making temporary copies.

We have to make copies in cases like this:

   ($a,$b) = func();

because func() could return ($b,$a).

If any op on either side is marked OA_DANGEROUS and not handled spe-
cially in op.c:S_aassign_scommon_vars, then it is assumed it could
return a scalar that is also elsewhere in the list, so a temp copy
is needed.

(I think some of the existing ops with this flag could drop it.)

regen/opcode.pl
regen/opcodes

index 10c708b..402929f 100755 (executable)
@@ -1082,7 +1082,7 @@ my %opflags = (
     'T' =>   8 | 16,   # ... which may be lexical
     'i' =>   0,                # always produces integer (unused since e7311069)
     'I' =>  32,                # has corresponding int op
-    'd' =>  64,                # danger, unknown side effects
+    'd' =>  64,                # danger, make temp copy in list assignment
     'u' => 128,                # defaults to $_
 );
 
index 07910ed..1e55ecb 100644 (file)
@@ -23,7 +23,7 @@
 #   needs a target                      - t  (OA_TARGET)
 #   target can be in a pad              - T  (OA_TARGET|OA_TARGLEX)
 #   has a corresponding integer version - I  (OA_OTHERINT)
-#   has side effects                    - d  (OA_DANGEROUS)
+#   make temp copy in list assignment   - d  (OA_DANGEROUS)
 #   uses $_ if no argument given        - u  (OA_DEFGV)
 
 # Values for the operands are: