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

But the 100k scalars don't show up in the optree. Where are they?

  • Comment on Re^6: Why is const x const not a const?

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

    I don't know why B::Concise doesn't dump the contents of array, but B::Concise does show that the array is in the optree.

    $ perl -MO=Concise,-exec -e'my @a = 1..1000' 1 <0> enter 2 <;> nextstate(main 1 -e:1) v:{ 3 <0> pushmark s 4 <$> const[AV ] s ^ | 5 <1> rv2av lKP/1 6 <0> pushmark s 7 <0> padav[@a:1,2] lRM*/LVINTRO 8 <2> aassign[t4] vKS/COMMON 9 <@> leave[1 ref] vKP/REFC -e syntax OK

      I know that the array is there, but that doesn't convince me that those 100k scalars are built at compile time. There might just as well be a magic initializer attached to it that generates them at runtime, or at closure cloning time or whenever.

      No matter how big I chose the number in the range, I can't see increased memory consumption at compile time, which is why i suspect they aren't created at compile time.

        I know that the array is there, but that doesn't convince me that those 100k scalars are built at compile time

        I showed the array is created at compile-time.

        I showed that once the list is built, it's not freed.

        I showed through memory usage monitoring that the list is built at compile-time.

        Not sure what else you want.

        No matter how big I chose the number in the range, I can't see increased memory consumption at compile time, which is why i suspect they aren't created at compile time.

        What's your test? Are you mistakenly using for (CONST..CONST) instead of the range operator?