Name : perl-Syntax-Keyword-Defer
| |
Version : 0.11
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : lp155.1.1
| Date : 2024-08-30 06:44:31
|
Group : Unspecified
| Source RPM : perl-Syntax-Keyword-Defer-0.11-lp155.1.1.src.rpm
|
Size : 0.06 MB
| |
Packager : https://www_suse_com/
| |
Summary : Execute code when leaving a block
|
Description :
This module provides a syntax plugin that implements a block which executes when the containing scope has finished.
It similar to features provided by other languages; Swift, Zig, Jai, Nim and Odin all provide this. Note that while Go also provides a \'defer\' keyword, the semantics here are not the same. Go\'s version defers until the end of the entire function, rather than the closest enclosing scope as is common to most other languages, and this module.
The operation can be considered a little similar to an \'END\' block, but with the following key differences:
* A \'defer\' block runs at the time that execution leaves the block it is declared inside, whereas an \'END\' block runs at the end time of the entire program regardless of its location.
* A \'defer\' block is invoked at the time its containing scope has finished, which means it might run again if the block is entered again later in the program. An \'END\' block will only ever run once.
* A \'defer\' block will only take effect if execution reaches the line it is declared on; if the line is not reached then nothing happens. An \'END\' block will always be invoked once declared, regardless of the dynamic extent of execution at runtime.
\'defer\' blocks are primarily intended for cases such as resource finalisation tasks that may be conditionally required.
For example in the synopsis code, after normal execution the statement handle will be finished using the \'$sth->finish\' method, then the database will be disconnected with \'$dbh->disconnect\'. If instead the prepare method failed then the database will still be disconnected, but there is no need to finish with the statement handle as the second \'defer\' block was never encountered.
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-S/15.5/x86_64 |