in reply to Re: Playing with (macro/source-filter) fire
in thread Playing with (macro/source-filter) fire

After running your version of the code on my machine I notice a couple of differences between your results and mine. When you print out the results of the compiled and deparsed macro, you get...
MACRO (COMPILED & DEPARSED): while ($var3 < $cons4) { $body6; } continue { ++$var5 }
while I get...
MACRO (COMPILED & DEPARSED): $var1 = $cons2; while ($var3 < $cons4) { $body6; } continue { ++$var5 }
...I notice that the first line $var1 = $cons2; is missing in your report. And strangely enough there's a line is missing from your compilied and deparsed source code ...
SOURCE (COMPILED & DEPARSED): my $x; while ($x < 8) { my $f = fact($x); print "factorial($x)=$f\n"; } continue { ++$x } sub fact { $_[0] <= 0 and return 1; return $_[0] * fact($_[0] - 1); } '???';
vs. my machine
SOURCE (COMPILED & DEPARSED): my $x; $x = 0; while ($x < 8) { my $f = fact($x); print "factorial($x)=$f\n"; } continue { ++$x } sub fact { $_[0] <= 0 and return 1; return $_[0] * fact($_[0] - 1); }
...the $x = 0; has gone missing. So this causes $reorder to differ...
REORDER: $var3 = $1;$cons4 = $2;$body6 = $3;$var5 = $4;
vs.
REORDER: $var1 = $1;$cons2 = $2;$var3 = $3;$cons4 = $4;$body6 = $5;$va +r5 = $6;
and is probably what causes the substitution match failure and thus you get the original code back. I don't know why lines would suddenly dissapear. Is it a buffering problem with the back-tick operator?

update:I'd try just running...

perl -MO=Deparse,-x9 -e'for($i=0;$i<10;$i++){$x++}'

...all by itself and see if it matches...

$i = 0; while ($i < 10) { ++$x; } continue { ++$i }
That's straight from 3rd edition camel p. 480. Anyone else have any ideas? BTW, I'm running perl 5.6.1 under Slackware Linux

Replies are listed 'Best First'.
Re: strange differences...
by stvn (Monsignor) on Jan 23, 2004 at 21:58 UTC

    Hmm, I re-downloaded all your code, tried it again, no go. My guess is that B::Deparse on OS X is different that Linux. My version of Deparse is one behind the latest, so that might play a role in this.

    Cool stuff none the less, thanks for showing your output, so I could see the guts of what it was doing though.

    -stvn