in reply to Re^5: Why is const x const not a const?
in thread Why is const x const not a const?

It shows up as const AV in the opcode tree.

You can prove the list is flattened once using

I see the 1 & 2, and 4 & 8 as consts, but I'm also seeing what look to me like two loops. Perhaps you can interpret it better?:

c:\test>perl -MO=Concise for (1..2) { for (4..8) { say $_++; } } ^Z t <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 4 -:1) v:{ ->3 s <2> leaveloop vK/2 ->t 7 <{> enteriter(next->p last->s redo->8) lKS/8 ->q - <0> ex-pushmark s ->3 - <1> ex-list lK ->6 3 <0> pushmark s ->4 4 <$> const[IV 1] s ->5 5 <$> const[IV 2] s ->6 6 <#> gv[*_] s ->7 - <1> null vK/1 ->s r <|> and(other->8) vK/1 ->s q <0> iter s ->r - <@> lineseq vKP ->- 8 <;> nextstate(main 2 -:2) v:{ ->9 o <2> leaveloop vK/2 ->p d <{> enteriter(next->l last->o redo->e) lKS/8 ->m - <0> ex-pushmark s ->9 - <1> ex-list lK ->c 9 <0> pushmark s ->a a <$> const[IV 4] s ->b b <$> const[IV 8] s ->c c <#> gv[*_] s ->d - <1> null vK/1 ->o n <|> and(other->e) vK/1 ->o m <0> iter s ->n - <@> lineseq vKP ->- e <;> nextstate(main 1 -:3) v:{ ->f k <1> preinc[t7] vK/1 ->l j <1> entersub[t6] sKRMS/NO(),TARG ->k f <0> pushmark s ->g - <1> ex-rv2sv sKM/1 ->h g <#> gvsv[*_] s ->h h <$> method_named[PV "say"] s ->i i <1> rv2cv /NO() ->j l <0> unstack v ->m p <0> unstack v ->q - syntax OK

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

Replies are listed 'Best First'.
Re^7: Why is const x const not a const?
by ikegami (Patriarch) on Jan 23, 2012 at 18:48 UTC

    Sorry, there was a set of parens missing. (Fixed.) I was about to reply to your post that for (CONST..CONST) is a counting loop rather than a loop iterating over the result of a range operator. There is no range operator, so the range operator cannot be flattened. Try

    perl -e"<>; exit; @a = 1..100000;" perl -e"<>; exit; for ((), 1..100000) {}"

    Results:

    perl -e"<>; exit; for ((),1.. 1000) {} 1,252K perl -e"<>; exit; for ((),1.. 10000) {} 1,784K perl -e"<>; exit; for ((),1.. 100000) {} 6,028K perl -e"<>; exit; for ((),1..1000000) {} 45,212K

    Update: Added results.

      You are forcing the issue there with the otherwise pointless parens.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?

        Yes, I forced the use of the range operator. After all, we are talking about the range operator. I didn't say «for (CONST..CONST)» flattens; I said «CONST..CONST» does, and I was referring to the range operator.