Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[S02] Fix COMPILING pseudopackage example.
The example seemed to show a misunderstanding of BEGIN blocks, at least
by our undestanding :) . Fixed so that the BEGIN blocks work like they
were intended, by moving each in a separate closure.
  • Loading branch information
ShimmerFairy committed May 18, 2013
1 parent 1bc6fed commit 81cf4c7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions S02-bits.pod
Expand Up @@ -3070,16 +3070,21 @@ variable sets or temporizes the incipient C<$?> variable in the
surrounding lexical scope that is being compiled. If nothing in
the context is being compiled, an exception is thrown.

$?FOO // say "undefined"; # probably says undefined
BEGIN { COMPILING::<$?FOO> = 42 }
say $?FOO; # prints 42
{
say $?FOO; # prints 42
}
{
BEGIN { temp COMPILING::<$?FOO> = 43 } # temporizes to *compiling* block
say $?FOO; # prints 43
BEGIN { COMPILING::<$?FOO> = 44 }
}
{
BEGIN {
COMPILING::<$?FOO> = 44;
say COMPILING::<$?FOO>; # prints 44, but $?FOO probably undefined
}
say $?FOO; # prints 44
BEGIN { say COMPILING::<$?FOO> } # prints 44, but $?FOO probably undefined
}
say $?FOO; # prints 42 (left scope of temp above)
$?FOO = 45; # always an error
Expand Down

0 comments on commit 81cf4c7

Please sign in to comment.