Michael G Schwern <[EMAIL PROTECTED]> writes:
> On Mon, Jan 14, 2002 at 10:23:46AM +0000, Piers Cawley wrote:
>> Um... You're wrong. If you do need 'startup time' initialization then
>> you should do it in an INIT block. If I may quote from the
>> documentation:
>
> Like it or not, people put lots of init code into BEGIN blocks, if
> nothing else for backwards compatiblity with 5.005. perlcc has to
> compile real world programs.
Deferring BEGIN blocks 'til runtime will break rather more realworld
program than it fixes I think.
>
> Can't solve this with a "do not" rule.
>
>> Once a "BEGIN" has run, it is immediately unde?
>> fined and any code it used is returned to Perl's memory
>> pool. This means you can't ever explicitly call a
>> "BEGIN".
>>
>> So, by the time that the compiler comes to generate its output, the
>> BEGIN block as vanished, never to be seen again, which is as it should
>> be.
>
> There's a special B::save_BEGINs function which O.pm uses to get
> around this.
>
> 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 { ... }
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.
--
Piers
"It is a truth universally acknowledged that a language in
possession of a rich syntax must be in need of a rewrite."
-- Jane Austen?