On Mon, Jan 14, 2002 at 10:38:36PM +0000, Piers Cawley wrote:
> >> Deferring BEGIN blocks 'til runtime will break rather more realworld
> >> program than it fixes I think.
> >
> > Where is deferring involved?
> 
> Err... it goes like this:
> 
> <compile phase, includes BEGIN blocks and any modules that get 'use'd
> by the main program>
> <CHECK phase>
> <INIT phase>
> <Runtime>
> <END>
> 
> The compiled file gets dumped out at CHECK time as I think we said
> before. What you propose is to defer BEGIN processing to after the
> CHECK phase. So, how do you decide whether 
> 
> BEGIN {
>     push @INC, 'bibble';
> }
> 
> gets evaluated at compile time (which it should because it has far
> reaching effects about where stuff gets included from during
> compilation), or if it gets evaluated at runtime. Admittedly, this one
> is rather straightforward.

Oh, I think you misunderstand.  Everything gets evaluated like normal.
BEGIN blocks run, checks, whatever.  Then its all compiled and dumped.
The only difference I'm proposing is that any code in the BEGIN blocks
(mod use statements and whatnot) is also dumped.  So the resulting
C code mirrors what the original was doing.

You can get at the BEGIN code via B::save_BEGINs.  You can figure out
what's code and what's just a use statement.  You can squelch any
output with O.pm's -qq.

What's left?


> Meanwhile we *do* have INIT blocks will do what you want without doing
> the impossible. (Well, admittedly, educating programmers might well be
> nearly impossible too, but dammit the behaviour of BEGIN blocks has
> been *documented* since before there was a Perl compiler. And the
> behaviour of INIT and CHECK blocks have also been clearly documented
> since they were interested.
> 
> This really is a case of 'READ THE FSCKING MANUAL'.

Its also a case of "I'd rather not break backwards compatibility [1]
just to feed perlcc's neurosises".  

There's also the factor that for all intents and purposes, Joe Average
Programmer really shouldn't have to care about the difference between
BEGIN, INIT and CHECK.  In fact, they should be able to get along just
fine without ever knowing INIT and CHECK even exist.  Sort of like
*foo{HASH} and the finer points of the -D switch.


Its perlcc's job to reproduce the actions of the original code to the
best of its abilities.  It might turn out that its not possible.  This
is, after all, an experiment.


[1] I think they were in 5.005_XX, just not documented well until 5.6.

-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl Quality Assurance      <[EMAIL PROTECTED]>         Kwalitee Is Job One
Maybe they hooked you up with one of those ass-making magazines.
        -- brian d. foy as misheard by Michael G Schwern

Reply via email to