Debian Codegraph @

doc/index.html

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