On Fri, Mar 25, 2005 at 02:52:51PM +0800, Autrijus Tang wrote:
: So, as now Pugs generates PMC code that makes mandel.p6 run
: faster than Perl 5 (http://use.perl.org/~autrijus/journal/23829),
: I'm pondering this BEGIN{} mess that Pugs had not dealt with.
: 
: Consider this program, example.p6:
: 
:     use v6;
:     my $var = BEGIN { say "I'm compiling, man"; time() }
:     say "Compiled at { time() - $var } seconds ago!";
: 
: Is this behaviour correct?
: 
:     % pugscc --parrot example.p6
:     I'm compiling, man
:     % sleep 60
:     % parrot example.pmc
:     Compiled at 60 seconds ago!

Yes, that's correct.  The BEGIN resolves to a scalar time value at
compile time, so as far as the run-time system knows, you just said
something like

    my $var = 123456.789;

Larry

Reply via email to