diff options
author | Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> | 2021-07-27 14:55:14 +0100 |
---|---|---|
committer | Paul Evans <leonerd@leonerd.org.uk> | 2021-08-25 13:52:09 +0100 |
commit | f79e2ff95fbb22eaf18e130c7cba8a9d40be3d75 (patch) | |
tree | 18bedb48e757671114f8f63c8691677a06b62a1b /pod/perlmod.pod | |
parent | 4b21956ed64a9303ab72a46be1cd68c22bff2560 (diff) | |
download | perl-f79e2ff95fbb22eaf18e130c7cba8a9d40be3d75.tar.gz |
Create `defer` syntax and `OP_PUSHDEFER` opcode
Adds syntax `defer { BLOCK }` to create a deferred block; code that is
deferred until the scope exits. This syntax is guarded by
use feature 'defer';
Adds a new opcode, `OP_PUSHDEFER`, which is a LOGOP whose `op_other` field
gives the start of an optree to be deferred until scope exit. That op
pointer will be stored on the save stack and invoked as part of scope
unwind.
Included is support for `B::Deparse` to deparse the optree back into
syntax.
Diffstat (limited to 'pod/perlmod.pod')
-rw-r--r-- | pod/perlmod.pod | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/pod/perlmod.pod b/pod/perlmod.pod index fdfb3811e5..e1fc952e28 100644 --- a/pod/perlmod.pod +++ b/pod/perlmod.pod @@ -345,6 +345,10 @@ X<$?> Inside of a C<END> block, the value of C<${^GLOBAL_PHASE}> will be C<"END">. +Similar to an C<END> block are C<defer> blocks, though they operate on the +lifetime of individual block scopes, rather than the program as a whole. They +are documented in L<perlsyn/defer>. + C<UNITCHECK>, C<CHECK> and C<INIT> code blocks are useful to catch the transition between the compilation phase and the execution phase of the main program. |