1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Coxpcall - Coroutine Safe xpcall and pcall</title>
<link rel="stylesheet" href="doc.css" type="text/css"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"><a href="http://keplerproject.github.io/coxpcall/">
<img alt="coxpcall logo" src="coxpcall.png" width="128" height="128"/></a>
</div>
<div id="product_name"><big><strong>Coxpcall</strong></big></div>
<div id="product_description">Coroutine-safe <code>xpcall</code> and <code>pcall</code> versions</div>
</div> <!-- id="product" -->
<div id="main">
<div id="navigation">
<h1>Coxpcall</h1>
<ul>
<li><strong>Home</strong>
<ul>
<li><a href="index.html#over">Overview</a></li>
<li><a href="index.html#status">Status</a></li>
<li><a href="index.html#download">Download</a></li>
<li><a href="index.html#reference">Reference</a></li>
<li><a href="index.html#credits">Credits</a></li>
</ul>
</li>
<li><a href="http://keplerproject.github.io/coxpcall/">Project</a>
<ul>
<li><a href="https://github.com/keplerproject/coxpcall/issues">Bug Tracker</a></li>
<li><a href="https://github.com/keplerproject/coxpcall">Source code</a></li>
</ul>
</li>
<li><a href="license.html">License</a></li>
</ul>
</div> <!-- id="navigation" -->
<div id="content">
<h2><a name="over"></a>Overview</h2>
<p>Coxpcall encapsulates the protected calls with a coroutine based loop,
so errors can be dealed without the usual <code>pcall</code>/<code>xpcall</code>
issues with coroutines.
</p>
<p>Using Coxpcall usually consists in simply loading the module and then
replacing Lua <code>pcall</code>, <code>xpcall</code> and <code>coroutine.running</code>
by <code>copcall</code>, <code>coxpcall</code>, and <code>running</code>.</p>
<p>Coxpcall is free software and uses the same
<a href="license.html">license</a> as Lua 5.1 and 5.2.
</p>
<h2><a name="status"></a>Status</h2>
<p>It supports Lua 5.1, 5.2 and 5.3. Lua 5.2 was extended with the Coxpcall
functionality and hence coxpcall is no longer required. The
5.2+ compatibility by coxpcall means that it maintains backward compatibility
while using the built-in implementation.</p>
<h2><a name="download"></a>Download</h2>
<p>
You can get Coxpcall using <a href="http://luarocks.org">LuaRocks</a>:
</p>
<pre class="example">
luarocks install coxpcall
</pre>
<p>
See also its
<a href="https://github.com/keplerproject/coxpcall">GitHub</a> page.
</p>
<h2><a name="reference"></a>Reference</h2>
<p>Coxpcall module offers three functions that reproduce the behaviour of
<code>pcall</code>, <code>xpcall</code>, and <code>coroutine.running</code>:</p>
<pre class="example">
local coxpcall = require "coxpcall"
</pre>
<dl class="reference">
<dt><strong><code>coxpcall.xpcall(f, err)</code></strong></dt>
<dd>Offers the same functionality as Lua <code>xpcall(f, err)</code>,
but calls the error handler <em>after</em> the error unwinds the stack,
so that it's impossible to gather more information about the error.
To compensate, if the error is a string, stack trace is appended to it.
Also set as global <code>coxpcall</code>.</dd>
<dt><strong><code>coxpcall.pcall(f, ...)</code></strong></dt>
<dd>Offers the same functionality as Lua <code>pcall(f, ...)</code>.
Also set as global <code>copcall</code>.</dd>
<dt><strong><code>coxpcall.running([coro])</code></strong></dt>
<dd>Because <code>coxpcall</code> and <code>copcall</code> run the function to protect
inside a new coroutine, <code>coroutine.running()</code> will return an unexpected
coroutine when used inside the protected function. If the coroutine <code>coro</code> was
created by the coxpcall module, then <code>running(coro)</code> will return the original
coroutine that created it. If <code>coro</code> is not provided, it will default to the
currently running coroutine.</dd>
</dl>
<h2><a name="credits"></a>Credits</h2>
<p>
Coxpcall was designed and implemented by Roberto Ierusalimschy and
André Carregal with the colaboration of Thomas Harning Jr., Ignacio Burgueño,
Gary NG and Fábio Mascarenhas as part of the
<a href="https://github.com/keplerproject">Kepler Project</a> which holds its copyright.
</p>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<p><a href="http://validator.w3.org/check?uri=referer">Valid XHTML 1.0!</a></p>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>
|