Re: BEGIN and lexical variables inside subroutines

2005-05-14 Thread Larry Wall
On Fri, May 13, 2005 at 04:21:25PM +0200, "TSa (Thomas Sandlaß)" wrote: : 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. Whereas I hope that it *is* possible to intentionally mess up the internals of the com

Re: BEGIN and lexical variables inside subroutines

2005-05-13 Thread TSa (Thomas Sandlaß)
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 f

Re: BEGIN and lexical variables inside subroutines

2005-05-12 Thread Dave Mitchell
On Thu, May 12, 2005 at 09:06:48PM +0100, 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". > > Should BEGIN blocks be able to modify values in lexical variables that > don't really exist yet? (People ca

BEGIN and lexical variables inside subroutines

2005-05-12 Thread Benjamin Smith
sub foo { my $x; BEGIN { $x = 3 }; say $x } foo; foo; foo; Currently in perl5 and pugs this prints "3\n\n\n". Should BEGIN blocks be able to modify values in lexical variables that don't really exist yet? (People can use state after all to get a variable which does exist early enough for them