On Tue, Jan 15, 2002 at 08:51:06AM +0000, Piers Cawley wrote:
> > I don't understand.  Why do we have to deal with them?  Just translate
> > the Perl code in the BEGIN block to C <hand wave>, dump it and make
> > sure it gets run first.  Right?
> >
> > I think I'm missing something very vital here.
> 
> Let's see if I can come up with a simple counterexample that will show
> up the problem.
> 
>     #!perl
>     my($compile_time, $start_time);
>     BEGIN {$compile_time .= localtime(time)}
> 
>     # Later:
> 
>     print "Compiled at $compile_time\n";
>     print "Started at $start_time\n";
>    
>     ...
> 
>     BEGIN {$start_time .= localtime(time)}
>     __END__
> 
> How do you intend to distinguish between those two BEGIN blocks, one
> of which must be run at script compile time, the other of which must
> be run at (for want of a better description) INIT time? And neither of
> which can be run twice (hence the .=).

Wouldn't both of those BEGIN blocks be run at compile-time?  The only
ordering I'd see is that the first one declared (ie. $compile_time) is
run before the second (ie. $start_time).


> The only thing that can make that distinction is a human being. The
> compiler can probably guess that the two blocks should only be run
> once

Guess?  Its a BEGIN block, it gets run once!

Ok, there's some really fundemental breakdown of understanding here,
and I think its me.  Let's step back a second.  Why is anything
guessing when and how many times BEGIN blocks are run?

Is B::C literally dumping out the total state of the interpreter after
compile-time, variables and everything?!


-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl Quality Assurance      <[EMAIL PROTECTED]>         Kwalitee Is Job One
Paste is a waste if you're chaste,
but in this case dump a load
of goo and poo by the case in your face,
and place in your jawls like a juicy chaw,
but don't spit that shit and enjoy it all.
        -- Ubergirl's beau

Reply via email to