comparison website/src/diff.html.luan @ 479:1285c52ea9d4

add manual heading_options
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 11 May 2015 15:29:29 -0600
parents 9b51e2413cab
children 0db144c98564
comparison
equal deleted inserted replaced
478:eb6d90fb0b5c 479:1285c52ea9d4
1 local Io = require "luan:Io" 1 local Io = require "luan:Io"
2 local Html = require "luan:Html" 2 local Html = require "luan:Html"
3 local Http = require "luan:web/Http" 3 local Http = require "luan:web/Http"
4 local Shared = require "site:/Shared" 4 local Shared = require "site:/Shared"
5 5 local Manual = require "site:/manual.html"
6
7 heading_options = Manual.heading_options
6 8
7 function service() 9 function service()
8 Io.stdout = Http.response.text_writer() 10 Io.stdout = Http.response.text_writer()
9 %> 11 %>
10 <html> 12 <html>
65 </ul> 67 </ul>
66 </div> 68 </div>
67 69
68 <hr/> 70 <hr/>
69 71
70 <h2 margin-top="1em"><a name="intro">Introduction</a></h2> 72 <h2 <%=heading_options%> ><a name="intro">Introduction</a></h2>
71 73
72 <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> 74 <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>
73 75
74 <p>Luan is implemented in Java and is tightly integrated with Java. This makes it an excellent scripting language for Java.</p> 76 <p>Luan is implemented in Java and is tightly integrated with Java. This makes it an excellent scripting language for Java.</p>
75 77
76 <h2 margin-top="1em"><a name="basic">Basic Concepts</a></h2> 78 <h2 <%=heading_options%> ><a name="basic">Basic Concepts</a></h2>
77 79
78 <h3 margin-top="1em"><a name="types">Values and Types</a></h3> 80 <h3 <%=heading_options%> ><a name="types">Values and Types</a></h3>
79 81
80 <p>Luan does not have the Lua <i>thread</i> type. Luan adds a <i>binary</i> type that Lua doesn't have. This is because Lua strings can represent binary while Luan strings cannot.</p> 82 <p>Luan does not have the Lua <i>thread</i> type. Luan adds a <i>binary</i> type that Lua doesn't have. This is because Lua strings can represent binary while Luan strings cannot.</p>
81 83
82 <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> 84 <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>
83 85
87 89
88 <p>The Luan <i>binary</i> type is the Java <i>byte[ ]</i> type which is an array of bytes.</p> 90 <p>The Luan <i>binary</i> type is the Java <i>byte[ ]</i> type which is an array of bytes.</p>
89 91
90 <p>The Luan <i>table</i> type is just like its Lua equivalent, but implemented in Java.</p> 92 <p>The Luan <i>table</i> type is just like its Lua equivalent, but implemented in Java.</p>
91 93
92 <h3 margin-top="1em"><a name="env">Environments</a></h3> 94 <h3 <%=heading_options%> ><a name="env">Environments</a></h3>
93 95
94 <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> 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>
95 97
96 <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> 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>
97 99
98 <h3 margin-top="1em"><a name="error">Error Handling</a></h3> 100 <h3 <%=heading_options%> ><a name="error">Error Handling</a></h3>
99 101
100 <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> 102 <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>
101 103
102 <h3 margin-top="1em"><a name="meta">Metatables and Metamethods</a></h3> 104 <h3 <%=heading_options%> ><a name="meta">Metatables and Metamethods</a></h3>
103 105
104 <p>Luan only has metatable for tables, not for other types.</p> 106 <p>Luan only has metatable for tables, not for other types.</p>
105 107
106 <h3 margin-top="1em"><a name="gc">Garbage Collection</a></h3> 108 <h3 <%=heading_options%> ><a name="gc">Garbage Collection</a></h3>
107 109
108 <p>Luan uses Java garbage collection. Luan has no special garbage collection methods.</p> 110 <p>Luan uses Java garbage collection. Luan has no special garbage collection methods.</p>
109 111
110 <p>Luan does not yet have weak tables but this will be added.</p> 112 <p>Luan does not yet have weak tables but this will be added.</p>
111 113
112 <h3 margin-top="1em"><a name="coroutines">Coroutines</a></h3> 114 <h3 <%=heading_options%> ><a name="coroutines">Coroutines</a></h3>
113 115
114 <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> 116 <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>
115 117
116 <h2 margin-top="1em"><a name="lang">The Language</a></h2> 118 <h2 <%=heading_options%> ><a name="lang">The Language</a></h2>
117 119
118 <h3 margin-top="1em"><a name="lex">Lexical Conventions</a></h3> 120 <h3 <%=heading_options%> ><a name="lex">Lexical Conventions</a></h3>
119 121
120 <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> 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>
121 123
122 <p>Luan has exactly the same set of keywords as Lua and has the same other lexical conventions.</p> 124 <p>Luan has exactly the same set of keywords as Lua and has the same other lexical conventions.</p>
123 125
124 <h3 margin-top="1em"><a name="stmt">Statements</a></h3> 126 <h3 <%=heading_options%> ><a name="stmt">Statements</a></h3>
125 127
126 <p>Most statements in Luan are the same as Lua. Only those statements that differ will be listed here.</p> 128 <p>Most statements in Luan are the same as Lua. Only those statements that differ will be listed here.</p>
127 129
128 <h4 margin-top="1em"><a name="control">Control Structures</a></h4> 130 <h4 <%=heading_options%> ><a name="control">Control Structures</a></h4>
129 131
130 <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> 132 <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>
131 133
132 <p>Luan does not have a <b>goto</b> statement.</p> 134 <p>Luan does not have a <b>goto</b> statement.</p>
133 135
134 <h4 margin-top="1em"><a name="for">For Statement</a></h4> 136 <h4 <%=heading_options%> ><a name="for">For Statement</a></h4>
135 137
136 <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> 138 <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>
137 139
138 <p><tt><pre> 140 <p><tt><pre>
139 for i in range(from,to,step) do <i>block</i> end 141 for i in range(from,to,step) do <i>block</i> end
156 block 158 block
157 end 159 end
158 end 160 end
159 </pre></tt></p> 161 </pre></tt></p>
160 162
161 <h4 margin-top="1em"><a name="logical">Logical Statements</a></h4> 163 <h4 <%=heading_options%> ><a name="logical">Logical Statements</a></h4>
162 164
163 <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> 165 <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>
164 166
165 <p><tt><pre> 167 <p><tt><pre>
166 x==5 or error "x should be 5" 168 x==5 or error "x should be 5"
167 </pre></tt></p> 169 </pre></tt></p>
168 170
169 <h4 margin-top="1em"><a name="template_stmt">Template Statements</a></h4> 171 <h4 <%=heading_options%> ><a name="template_stmt">Template Statements</a></h4>
170 172
171 <p>Template statements are a Luan addition that don't exist in Lua. See <a href="manual.html#template_stmt">Template Statements</a> in the Luan Reference Manual.</p> 173 <p>Template statements are a Luan addition that don't exist in Lua. See <a href="manual.html#template_stmt">Template Statements</a> in the Luan Reference Manual.</p>
172 174
173 175
174 <h3 margin-top="1em"><a name="expr">Expressions</a></h3> 176 <h3 <%=heading_options%> ><a name="expr">Expressions</a></h3>
175 177
176 <h4 margin-top="1em"><a name="conversions">Coercions and Conversions</a></h4> 178 <h4 <%=heading_options%> ><a name="conversions">Coercions and Conversions</a></h4>
177 179
178 <p>Unlike Lua, Luan does not do automatic conversions of strings to numbers.</p> 180 <p>Unlike Lua, Luan does not do automatic conversions of strings to numbers.</p>
179 181
180 <h4 margin-top="1em"><a name="bit">Bitwise Operators</a></h4> 182 <h4 <%=heading_options%> ><a name="bit">Bitwise Operators</a></h4>
181 183
182 <p>Bitwise operators appear to be a new addition to Lua 5.3 and didn't exist in Lua 5.2. Luan does not support bitwise operators, but these can be added if there is a need.</p> 184 <p>Bitwise operators appear to be a new addition to Lua 5.3 and didn't exist in Lua 5.2. Luan does not support bitwise operators, but these can be added if there is a need.</p>
183 185
184 <h4 margin-top="1em"><a name="logical_ops">Logical Operators</a></h4> 186 <h4 <%=heading_options%> ><a name="logical_ops">Logical Operators</a></h4>
185 187
186 <p>The only change in Luan is that <b>not</b> must take a boolean argument. This helps catch errors and makes code more readable.</p> 188 <p>The only change in Luan is that <b>not</b> must take a boolean argument. This helps catch errors and makes code more readable.</p>
187 189
188 <h4 margin-top="1em"><a name="concatenation">Concatenation</a></h4> 190 <h4 <%=heading_options%> ><a name="concatenation">Concatenation</a></h4>
189 191
190 <p>Unlike Lua, Luan converts all concatenation operands to strings. 192 <p>Unlike Lua, Luan converts all concatenation operands to strings.
191 193
192 <h4 margin-top="1em"><a name="fn_calls">Function Calls</a></h4> 194 <h4 <%=heading_options%> ><a name="fn_calls">Function Calls</a></h4>
193 195
194 <p>Luan does not support Lua's <tt>v:name(args)</tt> style object-oriented function call. Object oriented programming is done in Luan using closures, so this feature is not needed.</p> 196 <p>Luan does not support Lua's <tt>v:name(args)</tt> style object-oriented function call. Object oriented programming is done in Luan using closures, so this feature is not needed.</p>
195 197
196 <h4 margin-top="1em"><a name="template_expr">Template Expressions</a></h4> 198 <h4 <%=heading_options%> ><a name="template_expr">Template Expressions</a></h4>
197 199
198 <p>Template expressions are a Luan addition that don't exist in Lua. See <a href="manual.html#template_expr">Template Expressions</a> in the Luan Reference Manual.</p> 200 <p>Template expressions are a Luan addition that don't exist in Lua. See <a href="manual.html#template_expr">Template Expressions</a> in the Luan Reference Manual.</p>
199 201
200 </div> 202 </div>
201 203