in reply to Re: Re: Is for(@$array_ref) construct optimized? YES!
in thread Is for(@$array_ref) construct optimized? YES!

On Linux with Perl5.6.0:
$ perl -MO=Deparse -we '$x=[];for($i=0;$i<=$#x;$i++){}'
$x = [];
$i = 0;
while ($i <= $#x) {
    ();
}
continue {
    ++$i
}
-e syntax OK
Screamer is right - but thanks for preaching anyway, not all of us are 'converted' just yet. ;)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)
  • Comment on (jeffa) 3Re: Is for(@$array_ref) construct optimized? YES!

Replies are listed 'Best First'.
Re: (jeffa) 3Re: Is for(@$array_ref) construct optimized? YES!
by Weasel (Sexton) on Jun 16, 2002 at 20:34 UTC
    Aha! we see a difference between 5.6.0 and 5.6.1 with respect to this:
    D:\Perl56\bin>perl -MO=Deparse -we "$x=[];for($i=0;$i<=$#x;$i++){}" $x = []; $i = 0; while ($i <= $#x) { (); } continue { ++$i } -e syntax OK D:\>perl -MO=Deparse -we "$x=[];for($i=0;$i<=$#x;$i++){}" $x = []; for ($i = 0; $i <= $#x; ++$i) { (); } -e syntax OK
    Here I tried to compare 5.6.0 (I called it from 5.6.0 dir which is d:\perl56\bin in my computer) and 5.6.1 (it's in my $PATH)

    update I did update to call a snippet without compile errors; but explanation of results before and after update are same

      It's the B::Deparse version, not the Perl version that matters here.

      Makeshifts last the longest.

        I see, and this unsurprises me: newer B::Deparse understands additional typical constructs and resolves them. Isn't this bad? Don't know. I consider this improvement as not good, because before this day I used B::Deparse as a way to see into internal representation, and now I understand this is not 100% working.

        Thank you for clarifying!