Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
GNU Octave
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Unwind-protect=== Octave supports a limited form of [[exception handling]] modelled after the [http://www.lispworks.com/documentation/HyperSpec/Body/s_unwind.htm <code>unwind_protect</code>] of [[Lisp (programming language)|Lisp]]. The general form of an unwind_protect block looks like this: <syntaxhighlight lang="octave"> unwind_protect body unwind_protect_cleanup cleanup end_unwind_protect </syntaxhighlight> As a general rule, GNU Octave recognizes as termination of a given <code>''block''</code> either the keyword <code>end</code> (which is compatible with the MATLAB language) or a more specific keyword <code>end''block''</code> or, in some cases, <code>end_''block''</code>. As a consequence, an <code>unwind_protect</code> block can be terminated either with the keyword <code>end_unwind_protect</code> as in the example, or with the more portable keyword <code>end</code>. The ''cleanup'' part of the block is always executed. In case an exception is raised by the ''body'' part, ''cleanup'' is executed immediately before propagating the exception outside the block <code>unwind_protect</code>. GNU Octave also supports another form of exception handling (compatible with the MATLAB language): <syntaxhighlight lang="matlab"> try body catch exception_handling end </syntaxhighlight> This latter form differs from an <code>unwind_protect</code> block in two ways. First, ''exception_handling'' is only executed when an exception is raised by ''body''. Second, after the execution of ''exception_handling'' the exception is not propagated outside the block (unless a <code>rethrow( lasterror )</code> statement is explicitly inserted within the ''exception_handling'' code).
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)