Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 7ebd25ac536d248d499a3ce2acda963a > files > 5274

Macaulay2-1.3.1-8.fc15.i686.rpm

<?xml version="1.0" encoding="utf-8" ?>  <!-- for emacs: -*- coding: utf-8 -*- -->
<!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"	 "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head><title>try -- catch an error</title>
<link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/>
</head>
<body>
<table class="buttons">
  <tr>
    <td><div><a href="_catch.html">next</a> | <a href="_error.html">previous</a> | forward | <a href="_error.html">backward</a> | <a href="_error_sphandling.html">up</a> | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div>

    </td>
  </tr>
</table>
<div><a href="index.html" title="">Macaulay2Doc</a> > <a href="___The_sp__Macaulay2_splanguage.html" title="">The Macaulay2 language</a> > <a href="_error_sphandling.html" title="signalling and trapping errors">error handling</a> > <a href="_try.html" title="catch an error">try</a></div>
<hr/>
<div><h1>try -- catch an error</h1>
<div class="single"><h2>Synopsis</h2>
<ul><li><div class="list"><dl class="element"><dt class="heading">Usage: </dt><dd class="value"><div><tt>try x then y else z</tt></div>
</dd></dl>
</div>
</li>
<li><div class="single">Inputs:<ul><li><span><tt>x</tt>, code</span></li>
<li><span><tt>y</tt>, code</span></li>
<li><span><tt>z</tt>, code</span></li>
</ul>
</div>
</li>
<li><div class="single">Consequences:<ul><li>the code <tt>x</tt> is run; if no error or <a href="_alarm.html" title="set an alarm">alarm</a> occurs, then the code <tt>y</tt> is run; otherwise, the code <tt>z</tt> is run</li>
</ul>
</div>
</li>
</ul>
</div>
<div class="single"><h2>Description</h2>
<div>The return value is the value returned by <tt>y</tt> or <tt>z</tt>, as the case may be.<p/>
The clause '<tt>then y</tt>' may be omitted, in which case the return value is the value returned by <tt>x</tt>, if there is no error or alarm.<p/>
The clauses '<tt>then y else z</tt>' may both be omitted, in which case the return value is the value returned by <tt>x</tt>, unless an error or alarm occurs, in which case <a href="_null.html" title="the unique member of the empty class">null</a> is returned.<p/>
The behavior of interrupts (other than alarms) is unaffected.<table class="examples"><tr><td><pre>i1 : apply(-3..3,i->try 1/i else infinity)

        1    1                   1  1
o1 = (- -, - -, -1, infinity, 1, -, -)
        3    2                   2  3

o1 : Sequence</pre>
</td></tr>
</table>
</div>
</div>
<div class="single"><h2>Caveat</h2>
<div>We will change the behavior of this function soon so that it will be possible to catch errors of a particular type.  Meanwhile, users are recommended to use this function sparingly, if at all.</div>
</div>
<div class="waystouse"><h2>For the programmer</h2>
<p>The object <a href="_try.html" title="catch an error">try</a> is <span>a <a href="___Keyword.html">keyword</a></span>.</p>
</div>
</div>
</body>
</html>