comparison website/src/diff.html.luan @ 512:d96944467ffc

update documentation for luan changes
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 22 May 2015 16:08:23 -0600
parents 7bc63886d4f2
children 0dfc01d8d42d
comparison
equal deleted inserted replaced
511:e3fb9768dbb3 512:d96944467ffc
42 42
43 <div margin-bottom="1em"> 43 <div margin-bottom="1em">
44 <a href="#lang">The Language</a> 44 <a href="#lang">The Language</a>
45 <ul> 45 <ul>
46 <li><a href="#lex">Lexical Conventions</a></li> 46 <li><a href="#lex">Lexical Conventions</a></li>
47 <li><a href="#vars">Variables</a></li>
47 <li> 48 <li>
48 <a href="#stmt">Statements</a> 49 <a href="#stmt">Statements</a>
49 <ul> 50 <ul>
50 <li><a href="#control">Control Structures</a></li> 51 <li><a href="#control">Control Structures</a></li>
51 <li><a href="#for">For Statement</a></li> 52 <li><a href="#for">For Statement</a></li>
91 92
92 <p>The Luan <i>table</i> type is just like its Lua equivalent, but implemented in Java.</p> 93 <p>The Luan <i>table</i> type is just like its Lua equivalent, but implemented in Java.</p>
93 94
94 <h3 <%=heading_options%> ><a name="env">Environments</a></h3> 95 <h3 <%=heading_options%> ><a name="env">Environments</a></h3>
95 96
96 <p>Luan has an <tt>_ENV</tt> which is like its Lua equivalent. However Luan has no global environment at all, no <tt>_G</tt>.</p> 97 <p>Luan has no global environment at all, no <tt>_G</tt>. By default, Luan doesn't define <tt>_ENV</tt> either, but if you define it as a local table in a chunk, then it acts like it does in Lua. When <tt>_ENV</tt> isn't defined, there are no global variables and an unrecognized variable name produces a compile error.</p>
97 98
98 <p>Every module is initialized with two local functions: <tt>require</tt> and <tt>java</tt>. The module then uses these functions to get access to whatever else it needs.</p> 99 <p>Every module is initialized with two local functions: <tt>require</tt> and <tt>java</tt>. The module then uses these functions to get access to whatever else it needs.</p>
99 100
100 <h3 <%=heading_options%> ><a name="error">Error Handling</a></h3> 101 <h3 <%=heading_options%> ><a name="error">Error Handling</a></h3>
101 102
120 <h3 <%=heading_options%> ><a name="lex">Lexical Conventions</a></h3> 121 <h3 <%=heading_options%> ><a name="lex">Lexical Conventions</a></h3>
121 122
122 <p>Unlike Lua, Luan generally considers the end of a line to be the end of a statement. This catches errors and encourages readability. The exception to this is in paranthesis ( <i>(...)</i>, <i>[...]</i>, and <i>{...}</i> ) where the end of line is treated as white space.</p> 123 <p>Unlike Lua, Luan generally considers the end of a line to be the end of a statement. This catches errors and encourages readability. The exception to this is in paranthesis ( <i>(...)</i>, <i>[...]</i>, and <i>{...}</i> ) where the end of line is treated as white space.</p>
123 124
124 <p>Luan has exactly the same set of keywords as Lua and has the same other lexical conventions.</p> 125 <p>Luan has exactly the same set of keywords as Lua and has the same other lexical conventions.</p>
126
127 <h3 <%=heading_options%> ><a name="vars">Variables</a></h3>
128
129 <p>
130 By default, there are no global variables and an undefined variable produces a compile error. To enable global variables, one must define <tt>_ENV</tt>. Avoiding global variables makes it much easier to catch errors at compile time.
125 131
126 <h3 <%=heading_options%> ><a name="stmt">Statements</a></h3> 132 <h3 <%=heading_options%> ><a name="stmt">Statements</a></h3>
127 133
128 <p>Most statements in Luan are the same as Lua. Only those statements that differ will be listed here.</p> 134 <p>Most statements in Luan are the same as Lua. Only those statements that differ will be listed here.</p>
129 135