ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Guard/README
(Generate patch)

Comparing Guard/README (file contents):
Revision 1.6 by root, Fri Mar 12 17:25:58 2010 UTC vs.
Revision 1.7 by root, Sat Jul 2 00:38:44 2011 UTC

30FUNCTIONS 30FUNCTIONS
31 This module currently exports the "scope_guard" and "guard" functions by 31 This module currently exports the "scope_guard" and "guard" functions by
32 default. 32 default.
33 33
34 scope_guard BLOCK 34 scope_guard BLOCK
35 scope_guard ($coderef)
35 Registers a block that is executed when the current scope (block, 36 Registers a block that is executed when the current scope (block,
36 function, method, eval etc.) is exited. 37 function, method, eval etc.) is exited.
37 38
38 See the EXCEPTIONS section for an explanation of how exceptions 39 See the EXCEPTIONS section for an explanation of how exceptions
39 (i.e. "die") are handled inside guard blocks. 40 (i.e. "die") are handled inside guard blocks.
77 78
78 # do something with the new timezone 79 # do something with the new timezone
79 } 80 }
80 81
81 my $guard = guard BLOCK 82 my $guard = guard BLOCK
83 my $guard = guard ($coderef)
82 Behaves the same as "scope_guard", except that instead of executing 84 Behaves the same as "scope_guard", except that instead of executing
83 the block on scope exit, it returns an object whose lifetime 85 the block on scope exit, it returns an object whose lifetime
84 determines when the BLOCK gets executed: when the last reference to 86 determines when the BLOCK gets executed: when the last reference to
85 the object gets destroyed, the BLOCK gets executed as with 87 the object gets destroyed, the BLOCK gets executed as with
86 "scope_guard". 88 "scope_guard".
159THANKS 161THANKS
160 Thanks to Marco Maisenhelder, who reminded me of the $Guard::DIED 162 Thanks to Marco Maisenhelder, who reminded me of the $Guard::DIED
161 solution to the problem of exceptions. 163 solution to the problem of exceptions.
162 164
163SEE ALSO 165SEE ALSO
164 Scope::Guard and Sub::ScopeFinalizer, which actually implement dynamic 166 Scope::Guard and Sub::ScopeFinalizer, which actually implement
165 guards only, not scoped guards, and have a lot higher CPU, memory and 167 dynamically scoped guards only, not the lexically scoped guards that
168 their documentation promises, and have a lot higher CPU, memory and
166 typing overhead. 169 typing overhead.
167 170
168 Hook::Scope, which has apparently never been finished and can corrupt 171 Hook::Scope, which has apparently never been finished and can corrupt
169 memory when used. 172 memory when used.
170 173
174 Scope::Guard seems to have a big SEE ALSO section for even more modules
175 like it.
176

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines