Benjamin Smith wrote:
  sub foo { my $x; BEGIN { $x = 3 }; say $x }
  foo; foo; foo;

Currently in perl5 and pugs this prints "3\n\n\n".

Which to me looks like a mix of runtime and compile time. Actually Dave Mitchell confirmed that this is the case in Perl 5. I have difficulty to regard this as a feature. I would expect $x to be undef in all three invocations.


Should BEGIN blocks be able to modify values in lexical
> variables that don't really exist yet?

I think S04 makes pretty clear, that BEGIN blocks are run
at compile time, which to me means that it runs in the
runtime---and lexical?---environment of the compiler.
And I guess it is as of now a bit underspecified what
is the API to the compiler in action. E.g. is $_ the
compiler?

And I hope that it is not possible to accidentially
mess up the internals of the compiler because code
in a BEGIN hits compiler data.
--
$TSa == all( none( @Larry ), one( @p6l ))

Reply via email to