Re(mov|writ)e two comments from pad.c:pad_alloc
authorFather Chrysostomos <sprout@cpan.org>
Sun, 16 Jun 2013 19:40:05 +0000 (12:40 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 26 Jul 2013 06:47:59 +0000 (23:47 -0700)
The thing about "foreach" index vars was added in bbce6d697 (insepar-
able changes from patch from perl5.003_08 to perl5.003_09, presuma-
bly the ‘Lexical scoping cleanup’ part).  It is not valid, because
‘foreach’ doesn’t aliases a pad entry to a non-pad (not marked PADMY
or PADTMP) value until run time, and pad_alloc happens at compile
time.  The real reason we need this loop is that entries that close
over unavailable variables are not marked PADMY.  That may have been a
mistake, but it works because of this loop.  The reason for the loop
also may have changed over time.

The comment about copying to sv is not valid, because it is used later
on in the same condition when compared to &PL_sv_undef.  It was added
in commit dd2155a49b.

pad.c

diff --git a/pad.c b/pad.c
index 15b2656..ec3ad84 100644 (file)
--- a/pad.c
+++ b/pad.c
@@ -750,11 +750,11 @@ Perl_pad_alloc(pTHX_ I32 optype, U32 tmptype)
         const SSize_t names_fill = AvFILLp(PL_comppad_name);
        for (;;) {
            /*
-            * "foreach" index vars temporarily become aliases to non-"my"
-            * values.  Thus we must skip, not just pad values that are
+            * Entries that close over unavailable variables
+            * in outer subs contain values not marked PADMY.
+            * Thus we must skip, not just pad values that are
             * marked as current pad values, but also those with names.
             */
-           /* HVDS why copy to sv here? we don't seem to use it */
            if (++PL_padix <= names_fill &&
                   (sv = names[PL_padix]) && sv != &PL_sv_undef)
                continue;