comparison website/src/diff.html @ 1520:d9a5405a3102

try statement
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 21 Jun 2020 18:14:13 -0600
parents f5368cd8c056
children d3e61cd2aca0
comparison
equal deleted inserted replaced
1519:3ebf9781707c 1520:d9a5405a3102
43 <li> 43 <li>
44 <a href="#stmt">Statements</a> 44 <a href="#stmt">Statements</a>
45 <ul> 45 <ul>
46 <li><a href="#control">Control Structures</a></li> 46 <li><a href="#control">Control Structures</a></li>
47 <li><a href="#for">For Statement</a></li> 47 <li><a href="#for">For Statement</a></li>
48 <li><a href="#try">Try Statement</a></li>
48 <li><a href="#logical">Logical Statements</a></li> 49 <li><a href="#logical">Logical Statements</a></li>
49 <li><a href="#template_stmt">Template Statements</a></li> 50 <li><a href="#template_stmt">Template Statements</a></li>
50 </ul> 51 </ul>
51 </li> 52 </li>
52 <li> 53 <li>
93 94
94 <p>Every module is initialized with two local functions: <code>require</code> and <code>java</code>. The module then uses these functions to get access to whatever else it needs.</p> 95 <p>Every module is initialized with two local functions: <code>require</code> and <code>java</code>. The module then uses these functions to get access to whatever else it needs.</p>
95 96
96 <h3 heading><a name="error" href="#error">Error Handling</a></h3> 97 <h3 heading><a name="error" href="#error">Error Handling</a></h3>
97 98
98 <p>Luan has the functions <code>error</code> and <code>pcall</code> but does not have <code>xpcall</code>. Luan adds the function <code>try</code> which looks and acts like try-catch blocks in other languages. Luan errors are implemented as an error table, not as a message object.</p> 99 <p>Luan has the functions <code>error</code> but does not have <code>pcall</code> or <code>xpcall</code>. Luan adds the <a href="#try">try statement</a> instead. Luan errors are implemented as an error table, not as a message object.</p>
99 100
100 <h3 heading><a name="meta" href="#meta">Metatables and Metamethods</a></h3> 101 <h3 heading><a name="meta" href="#meta">Metatables and Metamethods</a></h3>
101 102
102 <p>Luan only has metatable for tables, not for other types.</p> 103 <p>Luan only has metatable for tables, not for other types.</p>
103 104
163 block 164 block
164 end 165 end
165 end 166 end
166 </pre> 167 </pre>
167 168
169
170 <h4 heading><a name="try" href="#for">Try Statement</a></h4>
171
172 <p>Unlike Lua, Luan has a <b>try</b> statement. See <a href="manual.html#try">Try Statement</a> in the Luan Reference Manual. This also eliminates the need for Lua's <b>pcall</b> function which Luan doesn't have.</p>
173
168 <h4 heading><a name="logical" href="#logical">Logical Statements</a></h4> 174 <h4 heading><a name="logical" href="#logical">Logical Statements</a></h4>
169 175
170 <p>Unlike Lua, Luan allows <b>or</b> and <b>and</b> expressions to be stand-alone statements. This is useful in cases like this:</p> 176 <p>Unlike Lua, Luan allows <b>or</b> and <b>and</b> expressions to be stand-alone statements. This is useful in cases like this:</p>
171 177
172 <pre> 178 <pre>