Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > b38d2da330d1936e5ab1307c039c4941 > files > 70

octave-doc-3.6.4-3.mga4.noarch.rpm

<html lang="en">
<head>
<title>Unwind-protect - Frequently asked questions about Octave (with answers)</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Frequently asked questions about Octave (with answers)">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Octave-Features.html#Octave-Features" title="Octave Features">
<link rel="prev" href="Increment-and-decrement-operators.html#Increment-and-decrement-operators" title="Increment and decrement operators">
<link rel="next" href="Built_002din-ODE-and-DAE-solvers.html#Built_002din-ODE-and-DAE-solvers" title="Built-in ODE and DAE solvers">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<a name="Unwind-protect"></a>
<a name="Unwind_002dprotect"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Built_002din-ODE-and-DAE-solvers.html#Built_002din-ODE-and-DAE-solvers">Built-in ODE and DAE solvers</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Increment-and-decrement-operators.html#Increment-and-decrement-operators">Increment and decrement operators</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Octave-Features.html#Octave-Features">Octave Features</a>
<hr>
</div>

<h3 class="section">5.9 Unwind-protect</h3>

<p><a name="index-Unwind_002dprotect-8"></a>
Octave supports a limited form of exception handling modeled after the
unwind-protect form of Lisp.  The general form of an
<code>unwind_protect</code> block looks like this:

<pre class="example">     unwind_protect
       <var>body</var>
     unwind_protect_cleanup
       <var>cleanup</var>
     end_unwind_protect
</pre>
   <p class="noindent">Where <var>body</var> and <var>cleanup</var> are both optional and may contain any
Octave expressions or commands.  The statements in <var>cleanup</var> are
guaranteed to be executed regardless of how control exits <var>body</var>.

   <p>The <code>unwind_protect</code> statement is often used to reliably restore
the values of global variables that need to be temporarily changed.

   <p><span class="sc">Matlab</span> can be made to do something similar with their
<code>OnCleanUp</code> function that was introduced in 2008a. Octave also has
<code>onCleanup</code> since version 3.4.0.

   </body></html>