Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
GNU Octave
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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).
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
GNU Octave
(section)
Add topic