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

And then there's 1..100_000 that creates an array and 100,000 scalars at compile-time.

Really? Can you demonstrate that?

Because I see no evidence for it:

c:\test>perl -le"++$n for 1..1e2; system qq[tasklist /nh /fi \"pid eq +$$\"] " perl.exe 7500 Console 1 5 +,716 K c:\test>perl -le"++$n for 1..1e3; system qq[tasklist /nh /fi \"pid eq +$$\"] " perl.exe 3676 Console 1 5 +,712 K c:\test>perl -le"++$n for 1..1e4; system qq[tasklist /nh /fi \"pid eq +$$\"] " perl.exe 6048 Console 1 5 +,732 K c:\test>perl -le"++$n for 1..1e5; system qq[tasklist /nh /fi \"pid eq +$$\"] " perl.exe 5648 Console 1 5 +,720 K c:\test>perl -le"++$n for 1..1e6; system qq[tasklist /nh /fi \"pid eq +$$\"] " perl.exe 8620 Console 1 5 +,736 K

Whilst the memory usage varies a little, it sometime goes down a few k when the notional size of this array increases by an order of magnitude?

Conversely, if you explicitly create an array of that size, the memory requirement increases by 100MB as expected:

c:\test>perl -le"@a = 1 .. 1e6; system qq[tasklist /nh /fi \"pid eq $$ +\"] " perl.exe 2664 Console 1 109 +,576 K

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^5: Why is const x const not a const?
by LanX (Saint) on Jan 24, 2012 at 14:05 UTC
    > Because I see no evidence for it:

    Not surprising

    for (START .. STOP) { }

    is magically optimized into an iterator to avoid building the list.

    But if you try

    for (reverse START .. STOP) { }

    instead, you will see the memory consumption, because that optimization is (unfortunately) missing here.

    Cheers Rolf