comparison website/src/diff.html.luan @ 465:47c7de1f2322

documentation work
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 07 May 2015 22:10:45 -0600
parents eddf7c73373b
children 9b51e2413cab
comparison
equal deleted inserted replaced
464:eddf7c73373b 465:47c7de1f2322
46 <a href="#stmt">Statements</a> 46 <a href="#stmt">Statements</a>
47 <ul> 47 <ul>
48 <li><a href="#control">Control Structures</a></li> 48 <li><a href="#control">Control Structures</a></li>
49 <li><a href="#for">For Statement</a></li> 49 <li><a href="#for">For Statement</a></li>
50 <li><a href="#logical">Logical Statements</a></li> 50 <li><a href="#logical">Logical Statements</a></li>
51 <li><a href="#template-stmt">Template Statements</a></li> 51 <li><a href="#template_stmt">Template Statements</a></li>
52 </ul> 52 </ul>
53 </li> 53 </li>
54 <li> 54 <li>
55 <a href="#expr">Expressions</a> 55 <a href="#expr">Expressions</a>
56 <ul> 56 <ul>
57 <li><a href="#conversions">Coercions and Conversions</a></li>
57 <li><a href="#bit">Bitwise Operators</a></li> 58 <li><a href="#bit">Bitwise Operators</a></li>
58 <li><a href="#local-ops">Logical Operators</a></li> 59 <li><a href="#logical_ops">Logical Operators</a></li>
59 <li><a href="#fn-call">Function Calls</a></li> 60 <li><a href="#concatenation">Concatenation</a></li>
60 <li><a href="#template-expr">Template Expressions</a></li> 61 <li><a href="#fn_calls">Function Calls</a></li>
62 <li><a href="#template_expr">Template Expressions</a></li>
61 </ul> 63 </ul>
62 </li> 64 </li>
63 </ul> 65 </ul>
64 </div> 66 </div>
65 67
97 99
98 <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> 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>
99 101
100 <h3 margin-top="1em"><a name="meta">Metatables and Metamethods</a></h3> 102 <h3 margin-top="1em"><a name="meta">Metatables and Metamethods</a></h3>
101 103
102 <p>to document later...</p> 104 <p>Luan only has metatable for tables, not for other types.</p>
103 105
104 <h3 margin-top="1em"><a name="gc">Garbage Collection</a></h3> 106 <h3 margin-top="1em"><a name="gc">Garbage Collection</a></h3>
105 107
106 <p>Luan uses Java garbage collection. Luan has no special garbage collection methods.</p> 108 <p>Luan uses Java garbage collection. Luan has no special garbage collection methods.</p>
107 109
162 164
163 <p><tt><pre> 165 <p><tt><pre>
164 x==5 or error "x should be 5" 166 x==5 or error "x should be 5"
165 </pre></tt></p> 167 </pre></tt></p>
166 168
167 <h4 margin-top="1em"><a name="template-stmt">Template Statements</a></h4> 169 <h4 margin-top="1em"><a name="template_stmt">Template Statements</a></h4>
168 170
169 <p>Template statements are based on <a href="#template-expr">template exressions</a> and provide the full equivalent of <a href="http://en.wikipedia.org/wiki/JavaServer_Pages">JSP</a> but in a general way. Template statements write the equivalent template exression to standard output. For example:</p> 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>
170 172
171 <p><tt><pre><%=Html.encode[[
172 local name = "Bob"
173 %>
174 Hello <%=name%>!
175 Bye <%=name%>.
176 <%
177 ]]%></pre></tt></p>
178
179 <p>is equivalent to the code:</p>
180
181 <p><tt><pre><%=Html.encode[[
182 local name = "Bob"
183 require("luan:Io").stdout.write( %>
184 Hello <%=name%>!
185 Bye <%=name%>.
186 <% )
187 ]]%></pre></tt></p>
188 173
189 <h3 margin-top="1em"><a name="expr">Expressions</a></h3> 174 <h3 margin-top="1em"><a name="expr">Expressions</a></h3>
190 175
176 <h4 margin-top="1em"><a name="conversions">Coercions and Conversions</a></h4>
177
178 <p>Unlike Lua, Luan does not do automatic conversions of strings to numbers.</p>
179
191 <h4 margin-top="1em"><a name="bit">Bitwise Operators</a></h4> 180 <h4 margin-top="1em"><a name="bit">Bitwise Operators</a></h4>
192 181
193 <p>Bitwise operators appear to be 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> 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>
194 183
195 <h4 margin-top="1em"><a name="local-ops">Logical Operators</a></h4> 184 <h4 margin-top="1em"><a name="logical_ops">Logical Operators</a></h4>
196 185
197 <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> 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>
198 187
199 <h4 margin-top="1em"><a name="fn-call">Function Calls</a></h4> 188 <h4 margin-top="1em"><a name="concatenation">Concatenation</a></h4>
189
190 <p>Unlike Lua, Luan converts all concatenation operands to strings.
191
192 <h4 margin-top="1em"><a name="fn_calls">Function Calls</a></h4>
200 193
201 <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> 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>
202 195
203 <h4 margin-top="1em"><a name="template-expr">Template Expressions</a></h4> 196 <h4 margin-top="1em"><a name="template_expr">Template Expressions</a></h4>
204 197
205 <p>Luan adds a new type of expression based on <a href="http://en.wikipedia.org/wiki/JavaServer_Pages">JSP</a> called template expressions. Template expressions return multiple values. Here is an example:</p> 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>
206
207 <p><tt><pre><%=Html.encode[[
208 local name = "Bob"
209 write( %>Hello <%=name%>!<% )
210 ]]%></pre></tt></p>
211
212 <p>This is equivalent to the code:</p>
213
214 <p><tt><pre>
215 local name = "Bob"
216 write( "Hello ", name, "!" )
217 </pre></tt></p>
218
219 <p>The strings in template expressions may be multiple lines.</p>
220 199
221 </div> 200 </div>
222 201
223 <% Html.simply_html_body_bottom() %> 202 <% Html.simply_html_body_bottom() %>
224 </body> 203 </body>