On Wed, 16 Jan 2002, Michael G Schwern wrote: >On Wed, Jan 16, 2002 at 08:45:26AM +0100, Paul Johnson wrote: >> The fundamental problem here is that BEGIN blocks have to run when they >> are compiled. This is documented. You can try to work out whether the >> BEGIN blocks can be rearranged and run at different times, but as Piers >> has pointed out, this is impossible in the general case. So if the >> BEGIN blocks are run at compile time, there's no point having them >> around at run time. This is the raison d'?tre of INIT blocks. > >Ok, lemme run this by you. > >Here's my conception of how perlcc/B::C works. The program is >compiled, the opcode tree is scanned and the appropriate C code is >written for each op in the program. Just like B::Deparse scans the >opcode tree and writes out Perl code. > >Which is why I'm having so much conceptual trouble with why BEGIN >blocks would be a problem. > >It seems that's wrong. That what perlcc/B::C does is 'freeze' the >current state of the interpreter after compilation, including the >values of variables, and then spit out appropriate C code for only >the post-compile opcode tree. Is this right?
Yes. That's what makes startup time faster ( but not run time, as you surely know ) >In which case, yes, I can see how BEGIN blocks would be >troublesome. :( Regards Mattia