On Mon, Jan 14, 2002 at 04:16:49PM +0000, Piers Cawley wrote:
> > Like I said, if B::Deparse can do it, B::C can.
>
> But it shouldn't. How do you distinguish between:
>
> use Foo;
>
> (needs to use 'Foo' before generating the compiled script, otherwise
> what's the bloody point?)
>
> and
>
> BEGIN { ... }
Using Deep Magic as demonstrated inside B::Deparse by begin_is_use().
Module::Info uses a rather simplified version for it's
modules_used() method.
Not easy, but definately a (mostly) solved problem.
> Also, as the docs for B::Deparse points out:
>
> we can't guarantee to produce BEGIN blocks or "use" declarations
> in exactly the right place.
>
> Which can become a big problem when you find that your compiled script
> doesn't work and there's no easy way of debugging the program that it
> thinks it's evaluating.
So is the answer to just exclude them entirely? That's the wrong way
out.
B::Deparse has slowly gotten very good at figuring out BEGIN blocks
from 'use' statements and putting them in the right places. Hard
fought knowledge. Steal from it.
I don't expect perlcc to magically become perfect overnight. What I
do expect is that the 'compiled programs won't run code in BEGIN
blocks' be treated as a bug and not a feature and to look around at
other bits of B which are taking a stab at solving these problems.
--
Michael G. Schwern <[EMAIL PROTECTED]> http://www.pobox.com/~schwern/
Perl Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One
Well, my work here is done. If you need me again, just admit that you're
screwed and die.