Mercurial Hosting > luan
comparison website/src/diff.html @ 1521:d3e61cd2aca0
docs and shell bug fix
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Thu, 25 Jun 2020 23:17:14 -0600 |
| parents | d9a5405a3102 |
| children | 0af6a9d6d12f |
comparison
equal
deleted
inserted
replaced
| 1520:d9a5405a3102 | 1521:d3e61cd2aca0 |
|---|---|
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>How Luan differs from Lua</title> | 4 <title>How Luan differs from Lua</title> |
| 5 <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| 5 <style> | 6 <style> |
| 6 @import "site.css"; | 7 @import "site.css"; |
| 7 </style> | 8 </style> |
| 8 </head> | 9 </head> |
| 9 <body> | 10 <body> |
| 90 | 91 |
| 91 <h3 heading><a name="env" href="#env">Environments</a></h3> | 92 <h3 heading><a name="env" href="#env">Environments</a></h3> |
| 92 | 93 |
| 93 <p>Luan has no global environment at all, no <code>_G</code>. By default, Luan doesn't define <code>_ENV</code> either, but if you define it as a local table in a chunk, then it acts like it does in Lua. When <code>_ENV</code> isn't defined, there are no global variables and an unrecognized variable name produces a compile error.</p> | 94 <p>Luan has no global environment at all, no <code>_G</code>. By default, Luan doesn't define <code>_ENV</code> either, but if you define it as a local table in a chunk, then it acts like it does in Lua. When <code>_ENV</code> isn't defined, there are no global variables and an unrecognized variable name produces a compile error.</p> |
| 94 | 95 |
| 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> | 96 <p>Every module is initialized with one local function: <code>require</code>. The module then uses this function to get access to whatever else it needs.</p> |
| 96 | 97 |
| 97 <h3 heading><a name="error" href="#error">Error Handling</a></h3> | 98 <h3 heading><a name="error" href="#error">Error Handling</a></h3> |
| 98 | 99 |
| 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> | 100 <p>Luan has the function <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> |
| 100 | 101 |
| 101 <h3 heading><a name="meta" href="#meta">Metatables and Metamethods</a></h3> | 102 <h3 heading><a name="meta" href="#meta">Metatables and Metamethods</a></h3> |
| 102 | 103 |
| 103 <p>Luan only has metatable for tables, not for other types.</p> | 104 <p>Luan only has metatable for tables, not for other types.</p> |
| 104 | 105 |
| 127 <p> | 128 <p> |
| 128 By default, there are no global variables and an undefined variable produces a compile error. To enable global variables, one must define <code>_ENV</code>. Avoiding global variables makes it much easier to catch errors at compile time. | 129 By default, there are no global variables and an undefined variable produces a compile error. To enable global variables, one must define <code>_ENV</code>. Avoiding global variables makes it much easier to catch errors at compile time. |
| 129 | 130 |
| 130 <h3 heading><a name="stmt" href="#stmt">Statements</a></h3> | 131 <h3 heading><a name="stmt" href="#stmt">Statements</a></h3> |
| 131 | 132 |
| 132 <p>Luan adds the block terminators <b>end_do</b>, <b>end_for</b>, <b>end_function</b>, <b>end_if</b>, and <b>end_while</b>. These can be used to end the appropriate block type, but <b>end</b> can also be used to end any block.</p> | 133 <p>Luan adds the block terminators <b>end_do</b>, <b>end_for</b>, <b>end_function</b>, <b>end_if</b>, <b>end_try</b>, and <b>end_while</b>. These can be used to end the appropriate block type, but <b>end</b> can also be used to end any block.</p> |
| 133 | 134 |
| 134 <p>Most statements in Luan are the same as Lua. Only those statements that differ will be listed here.</p> | 135 <p>Most statements in Luan are the same as Lua. Only those statements that differ will be listed here.</p> |
| 135 | 136 |
| 136 <h4 heading><a name="control" href="#control">Control Structures</a></h4> | 137 <h4 heading><a name="control" href="#control">Control Structures</a></h4> |
| 137 | 138 |
