comparison website/src/diff.html @ 354:705e4d6c3dbb

improve formatting of diff.html
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 14 Apr 2015 05:44:06 -0600
parents 38c19ecc384d
children c207be7cf45d
comparison
equal deleted inserted replaced
353:38c19ecc384d 354:705e4d6c3dbb
17 <div container> 17 <div container>
18 <h1>How Luan differs from Lua</h1> 18 <h1>How Luan differs from Lua</h1>
19 19
20 <p>This document explains how <a href="/">Luan</a> differs from <a href="http://www.lua.org">Lua</a> as described in the <a href="http://www.lua.org/manual/5.3/">Lua 5.3 Reference Manual</a>.</p> 20 <p>This document explains how <a href="/">Luan</a> differs from <a href="http://www.lua.org">Lua</a> as described in the <a href="http://www.lua.org/manual/5.3/">Lua 5.3 Reference Manual</a>.</p>
21 21
22 <h2>Contents</h2> 22 <h2 margin-top="1em">Contents</h2>
23 23
24 <p><a href="#intro">Introduction</a></p> 24 <div margin-bottom="1em"><a href="#intro">Introduction</a></div>
25 25
26 <p> 26 <div margin-bottom="1em">
27 <a href="#basic">Basic Concepts</a> 27 <a href="#basic">Basic Concepts</a>
28 <ul> 28 <ul>
29 <li><a href="#types">Values and Types</a></li> 29 <li><a href="#types">Values and Types</a></li>
30 <li><a href="#env">Environments</a></li> 30 <li><a href="#env">Environments</a></li>
31 <li><a href="#error">Error Handling</a></li> 31 <li><a href="#error">Error Handling</a></li>
32 <li><a href="#meta">Metatables and Metamethods</a></li> 32 <li><a href="#meta">Metatables and Metamethods</a></li>
33 <li><a href="#gc">Garbage Collection</a></li> 33 <li><a href="#gc">Garbage Collection</a></li>
34 <li><a href="#coroutines">Coroutines</a></li> 34 <li><a href="#coroutines">Coroutines</a></li>
35 </ul> 35 </ul>
36 </p> 36 </div>
37 37
38 <p> 38 <div margin-bottom="1em">
39 <a href="#lang">The Language</a> 39 <a href="#lang">The Language</a>
40 <ul> 40 <ul>
41 <li><a href="#lex">Lexical Conventions</a></li> 41 <li><a href="#lex">Lexical Conventions</a></li>
42 <li> 42 <li>
43 <a href="#stmt">Statements</a> 43 <a href="#stmt">Statements</a>
46 <li><a href="#for">For Statement</a></li> 46 <li><a href="#for">For Statement</a></li>
47 <li><a href="#logical">Logical Statements</a></li> 47 <li><a href="#logical">Logical Statements</a></li>
48 </ul> 48 </ul>
49 </li> 49 </li>
50 </ul> 50 </ul>
51 </p> 51 </div>
52 52
53 <h2><a name="intro">Introduction</a></h2> 53 <h2 margin-top="1em"><a name="intro">Introduction</a></h2>
54 54
55 <p>Lua is one of the simplest languages available, but Luan is even simpler. This means Luan removes more than it adds. Most of what is added is added in the library, not in the language itself.</p> 55 <p>Lua is one of the simplest languages available, but Luan is even simpler. This means Luan removes more than it adds. Most of what is added is added in the library, not in the language itself.</p>
56 56
57 <p>Luan is implemented in Java and is tightly integrated with Java. This makes it an excellent scripting language for Java.</p> 57 <p>Luan is implemented in Java and is tightly integrated with Java. This makes it an excellent scripting language for Java.</p>
58 58
59 <h2><a name="basic">Basic Concepts</a></h2> 59 <h2 margin-top="1em"><a name="basic">Basic Concepts</a></h2>
60 60
61 <h4 margin-top="1em"><a name="types">Values and Types</a></h4> 61 <h3 margin-top="1em"><a name="types">Values and Types</a></h3>
62 62
63 <p>Luan does not have the Lua <i>thread</i> type. Luan add a <i>binary</i> type that Lua doesn't have. This is because Lua strings can represent binary while Luan strings cannot.</p> 63 <p>Luan does not have the Lua <i>thread</i> type. Luan add a <i>binary</i> type that Lua doesn't have. This is because Lua strings can represent binary while Luan strings cannot.</p>
64 64
65 <p>The Luan <i>Nil</i> type is implemented as the Java <i>null</i>. The Luan <i>Boolean</i> type is implemented as the Java <i>Boolean</i> type. The Luan <i>Number</i> type is implemented as the Java <i>Number</i> type. The Luan <i>String</i> type is implemented as the Java <i>String</i> type. Actual numbers may be any subclass of the Java <i>Number</i> class.</p> 65 <p>The Luan <i>Nil</i> type is implemented as the Java <i>null</i>. The Luan <i>Boolean</i> type is implemented as the Java <i>Boolean</i> type. The Luan <i>Number</i> type is implemented as the Java <i>Number</i> type. The Luan <i>String</i> type is implemented as the Java <i>String</i> type. Actual numbers may be any subclass of the Java <i>Number</i> class.</p>
66 66
70 70
71 <p>The Luan <i>binary</i> type is the Java <i>byte[ ]</i> type which is an array of bytes.</p> 71 <p>The Luan <i>binary</i> type is the Java <i>byte[ ]</i> type which is an array of bytes.</p>
72 72
73 <p>The Luan <i>table</i> type is just like its Lua equivalent, but implemented in Java.</p> 73 <p>The Luan <i>table</i> type is just like its Lua equivalent, but implemented in Java.</p>
74 74
75 <h4 margin-top="1em"><a name="env">Environments</a></h4> 75 <h3 margin-top="1em"><a name="env">Environments</a></h3>
76 76
77 <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> 77 <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>
78 78
79 <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> 79 <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>
80 80
81 <h4 margin-top="1em"><a name="error">Error Handling</a></h4> 81 <h3 margin-top="1em"><a name="error">Error Handling</a></h3>
82 82
83 <p>Luan has the functions <tt>error</tt> and <tt>pcall</tt> but does not have <tt>xpcall</tt>. Luan adds the function <tt>try</tt> which looks and acts like try-catch blocks in other languages.</p> 83 <p>Luan has the functions <tt>error</tt> and <tt>pcall</tt> but does not have <tt>xpcall</tt>. Luan adds the function <tt>try</tt> which looks and acts like try-catch blocks in other languages.</p>
84 84
85 <h4 margin-top="1em"><a name="meta">Metatables and Metamethods</a></h4> 85 <h3 margin-top="1em"><a name="meta">Metatables and Metamethods</a></h3>
86 86
87 <p>to document later...</p> 87 <p>to document later...</p>
88 88
89 <h4 margin-top="1em"><a name="gc">Garbage Collection</a></h4> 89 <h3 margin-top="1em"><a name="gc">Garbage Collection</a></h3>
90 90
91 <p>Luan uses Java garbage collection. Luan has no special garbage collection methods.</p> 91 <p>Luan uses Java garbage collection. Luan has no special garbage collection methods.</p>
92 92
93 <p>Luan does not yet have weak tables but this will be added.</p> 93 <p>Luan does not yet have weak tables but this will be added.</p>
94 94
95 <h4 margin-top="1em"><a name="coroutines">Coroutines</a></h4> 95 <h3 margin-top="1em"><a name="coroutines">Coroutines</a></h3>
96 96
97 <p>Luan does not have coroutines. Coroutines is a complex concept that isn't needed in a simple language, so it was left out.</p> 97 <p>Luan does not have coroutines. Coroutines is a complex concept that isn't needed in a simple language, so it was left out.</p>
98 98
99 <h2><a name="lang">The Language</a></h2> 99 <h2 margin-top="1em"><a name="lang">The Language</a></h2>
100 100
101 <h4 margin-top="1em"><a name="lex">Lexical Conventions</a></h4> 101 <h3 margin-top="1em"><a name="lex">Lexical Conventions</a></h3>
102 102
103 <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> 103 <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>
104 104
105 <p>Luan has exactly the same set of keywords as Lua and has the same other lexical conventions.</p> 105 <p>Luan has exactly the same set of keywords as Lua and has the same other lexical conventions.</p>
106 106
107 <h4 margin-top="1em"><a name="stmt">Statements</a></h4> 107 <h3 margin-top="1em"><a name="stmt">Statements</a></h3>
108 108
109 <p>Most statements in Luan are the same as Lua. Only those statements that differ will be listed here.</p> 109 <p>Most statements in Luan are the same as Lua. Only those statements that differ will be listed here.</p>
110 110
111 <h5 margin-top="1em"><a name="control">Control Structures</a></h5> 111 <h4 margin-top="1em"><a name="control">Control Structures</a></h4>
112 112
113 <p>The Luan <b>if</b>, <b>while</b>, and <b>repeat</b> statement are the same as in Lua except that the condition expression must return a boolean value. Any other value type will produce an error. This helps catch errors and makes code more readable.</p> 113 <p>The Luan <b>if</b>, <b>while</b>, and <b>repeat</b> statement are the same as in Lua except that the condition expression must return a boolean value. Any other value type will produce an error. This helps catch errors and makes code more readable.</p>
114 114
115 <p>Luan does not have a <b>goto</b> statement.</p> 115 <p>Luan does not have a <b>goto</b> statement.</p>
116 116
117 <h5 margin-top="1em"><a name="for">For Statement</a></h5> 117 <h4 margin-top="1em"><a name="for">For Statement</a></h4>
118 118
119 <p>Luan has no numeric <b>for</b> statement. Luan only has generic <b>for</b> statement. Instead of the numeric <b>for</b> statement, Luan uses the <tt>range</tt> function in a generic <b>for</b> statement like this:</p> 119 <p>Luan has no numeric <b>for</b> statement. Luan only has generic <b>for</b> statement. Instead of the numeric <b>for</b> statement, Luan uses the <tt>range</tt> function in a generic <b>for</b> statement like this:</p>
120 120
121 <tt><pre> 121 <tt><pre>
122 for i in range(from,to,step) do <i>block</i> end 122 for i in range(from,to,step) do <i>block</i> end
139 block 139 block
140 end 140 end
141 end 141 end
142 </pre></tt> 142 </pre></tt>
143 143
144 <h5 margin-top="1em"><a name="logical">Logical Statements</a></h5> 144 <h4 margin-top="1em"><a name="logical">Logical Statements</a></h4>
145 145
146 <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> 146 <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>
147 147
148 <tt><pre> 148 <tt><pre>
149 x==5 or error "x should be 5" 149 x==5 or error "x should be 5"