On Sun, Jan 13, 2002 at 07:39:52PM +0100, Mattia Barbon wrote:
> > perlcc seems to be dropping BEGIN blocks entirely, that's the problem.
>
> No, that's correct. Explanation: if I have a module Foo
> ----
> package Foo;
> 
> $x = 1;
> print "AAA";
> 
> sub a { $x }
> 
> 1;
> ----
> and a main program foo.pl
> ----
> BEGIN { # think use Foo;, expanded for clarity
>     require Foo;
> }
> 
> print Foo::a();
> ----
> perl -MO=C foo.pl
> calls B::C::compile _after_ it ran the BEGIN blocks; this means that the 
> optree in Foo that initializes $x, and does "print AAA" has already been 
> freed. So, even if B::C could save BEGIN blocks, this is not a good 
> idea, for quite a lot of reasons.

$ bleadperl -MO=-qq,Deparse foo.plx
sub BEGIN {
    print "foo\n";
}
print "bar\n";

If B::Deparse can save BEGIN blocks, B::C can.


-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl Quality Assurance      <[EMAIL PROTECTED]>         Kwalitee Is Job One
I have this god-awful need to aquire useless crap!!!

Reply via email to