annotate website/src/diff.html.luan @ 519:72610ddea6a7

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 27 May 2015 01:24:27 -0600
parents 0dfc01d8d42d
children 7cc9d4a53d3b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
1 local Io = require "luan:Io"
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
2 local Html = require "luan:Html"
494
2b9bc97f0439 change luan:web to luan:http
Franklin Schmidt <fschmidt@gmail.com>
parents: 483
diff changeset
3 local Http = require "luan:http/Http"
387
23d075ce1e48 add website/src/Shared.luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 386
diff changeset
4 local Shared = require "site:/Shared"
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
5 local Manual = require "site:/manual.html"
505
7bc63886d4f2 web page modules now return a function
Franklin Schmidt <fschmidt@gmail.com>
parents: 503
diff changeset
6 local heading_options = Shared.heading_options
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7
503
92c3d22745b8 make _ENV optional
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
8
505
7bc63886d4f2 web page modules now return a function
Franklin Schmidt <fschmidt@gmail.com>
parents: 503
diff changeset
9 return function()
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
10 Io.stdout = Http.response.text_writer()
391
2f5cc9c2cbf0 replace Html.simply_html_page with simply_html_head and simply_html_body_bottom
Franklin Schmidt <fschmidt@gmail.com>
parents: 390
diff changeset
11 %>
2f5cc9c2cbf0 replace Html.simply_html_page with simply_html_head and simply_html_body_bottom
Franklin Schmidt <fschmidt@gmail.com>
parents: 390
diff changeset
12 <html>
2f5cc9c2cbf0 replace Html.simply_html_page with simply_html_head and simply_html_body_bottom
Franklin Schmidt <fschmidt@gmail.com>
parents: 390
diff changeset
13 <head>
2f5cc9c2cbf0 replace Html.simply_html_page with simply_html_head and simply_html_body_bottom
Franklin Schmidt <fschmidt@gmail.com>
parents: 390
diff changeset
14 <% Html.simply_html_head() %>
2f5cc9c2cbf0 replace Html.simply_html_page with simply_html_head and simply_html_body_bottom
Franklin Schmidt <fschmidt@gmail.com>
parents: 390
diff changeset
15 <title>How Luan differs from Lua</title>
2f5cc9c2cbf0 replace Html.simply_html_page with simply_html_head and simply_html_body_bottom
Franklin Schmidt <fschmidt@gmail.com>
parents: 390
diff changeset
16 </head>
2f5cc9c2cbf0 replace Html.simply_html_page with simply_html_head and simply_html_body_bottom
Franklin Schmidt <fschmidt@gmail.com>
parents: 390
diff changeset
17 <body>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
19 <div container>
387
23d075ce1e48 add website/src/Shared.luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 386
diff changeset
20 <% Shared.header() %>
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
21 <h1>How Luan differs from Lua</h1>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
23 <p>This document explains how Luan 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>
372
f08cefa4594c start editing manual
Franklin Schmidt <fschmidt@gmail.com>
parents: 370
diff changeset
24
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
25 <hr/>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
27 <h2>Contents</h2>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
28
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
29 <div margin-bottom="1em"><a href="#intro">Introduction</a></div>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
31 <div margin-bottom="1em">
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
32 <a href="#basic">Basic Concepts</a>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
33 <ul>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
34 <li><a href="#types">Values and Types</a></li>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
35 <li><a href="#env">Environments</a></li>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
36 <li><a href="#error">Error Handling</a></li>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
37 <li><a href="#meta">Metatables and Metamethods</a></li>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
38 <li><a href="#gc">Garbage Collection</a></li>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
39 <li><a href="#coroutines">Coroutines</a></li>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
40 </ul>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
41 </div>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
43 <div margin-bottom="1em">
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
44 <a href="#lang">The Language</a>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
45 <ul>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
46 <li><a href="#lex">Lexical Conventions</a></li>
512
d96944467ffc update documentation for luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 505
diff changeset
47 <li><a href="#vars">Variables</a></li>
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
48 <li>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
49 <a href="#stmt">Statements</a>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
50 <ul>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
51 <li><a href="#control">Control Structures</a></li>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
52 <li><a href="#for">For Statement</a></li>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
53 <li><a href="#logical">Logical Statements</a></li>
465
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
54 <li><a href="#template_stmt">Template Statements</a></li>
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
55 </ul>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
56 </li>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
57 <li>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
58 <a href="#expr">Expressions</a>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
59 <ul>
465
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
60 <li><a href="#conversions">Coercions and Conversions</a></li>
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
61 <li><a href="#bit">Bitwise Operators</a></li>
465
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
62 <li><a href="#logical_ops">Logical Operators</a></li>
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
63 <li><a href="#concatenation">Concatenation</a></li>
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
64 <li><a href="#fn_calls">Function Calls</a></li>
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
65 <li><a href="#template_expr">Template Expressions</a></li>
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
66 </ul>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
67 </li>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
68 </ul>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
69 </div>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
70
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
71 <hr/>
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
72
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
73 <h2 <%=heading_options%> ><a name="intro">Introduction</a></h2>
372
f08cefa4594c start editing manual
Franklin Schmidt <fschmidt@gmail.com>
parents: 370
diff changeset
74
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
75 <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>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
76
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
77 <p>Luan is implemented in Java and is tightly integrated with Java. This makes it an excellent scripting language for Java.</p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
78
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
79 <h2 <%=heading_options%> ><a name="basic">Basic Concepts</a></h2>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
80
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
81 <h3 <%=heading_options%> ><a name="types">Values and Types</a></h3>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
82
464
eddf7c73373b fix references in the manual
Franklin Schmidt <fschmidt@gmail.com>
parents: 391
diff changeset
83 <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>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
84
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
85 <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>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
86
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
87 <p>Luan functions may be written in Luan or may be wrappers around native Java methods. Any Java method may be called as a Luan function.</p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
88
513
0dfc01d8d42d rename type "userdata" to "java"
Franklin Schmidt <fschmidt@gmail.com>
parents: 512
diff changeset
89 <p>The Luan <i>java</i> type is a replacement for Lua's <i>userdata</i>. A Luan <i>java</i> value is nothing more than a Java object that doesn't fall into one of the other recognized types.</p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
90
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
91 <p>The Luan <i>binary</i> type is the Java <i>byte[ ]</i> type which is an array of bytes.</p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
92
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
93 <p>The Luan <i>table</i> type is just like its Lua equivalent, but implemented in Java.</p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
94
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
95 <h3 <%=heading_options%> ><a name="env">Environments</a></h3>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
96
512
d96944467ffc update documentation for luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 505
diff changeset
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>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
98
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
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>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
100
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
101 <h3 <%=heading_options%> ><a name="error">Error Handling</a></h3>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
102
483
Franklin Schmidt <fschmidt@gmail.com>
parents: 479
diff changeset
103 <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. Luan errors are implemented as an error table, not as a message object.</p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
104
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
105 <h3 <%=heading_options%> ><a name="meta">Metatables and Metamethods</a></h3>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
106
465
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
107 <p>Luan only has metatable for tables, not for other types.</p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
108
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
109 <h3 <%=heading_options%> ><a name="gc">Garbage Collection</a></h3>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
110
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
111 <p>Luan uses Java garbage collection. Luan has no special garbage collection methods.</p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
112
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
113 <p>Luan does not yet have weak tables but this will be added.</p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
114
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
115 <h3 <%=heading_options%> ><a name="coroutines">Coroutines</a></h3>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
116
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
117 <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>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
118
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
119 <h2 <%=heading_options%> ><a name="lang">The Language</a></h2>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
120
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
121 <h3 <%=heading_options%> ><a name="lex">Lexical Conventions</a></h3>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
122
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
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>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
124
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
125 <p>Luan has exactly the same set of keywords as Lua and has the same other lexical conventions.</p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
126
512
d96944467ffc update documentation for luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 505
diff changeset
127 <h3 <%=heading_options%> ><a name="vars">Variables</a></h3>
d96944467ffc update documentation for luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 505
diff changeset
128
d96944467ffc update documentation for luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 505
diff changeset
129 <p>
d96944467ffc update documentation for luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 505
diff changeset
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.
d96944467ffc update documentation for luan changes
Franklin Schmidt <fschmidt@gmail.com>
parents: 505
diff changeset
131
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
132 <h3 <%=heading_options%> ><a name="stmt">Statements</a></h3>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
133
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
134 <p>Most statements in Luan are the same as Lua. Only those statements that differ will be listed here.</p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
135
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
136 <h4 <%=heading_options%> ><a name="control">Control Structures</a></h4>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
137
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
138 <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>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
139
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
140 <p>Luan does not have a <b>goto</b> statement.</p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
141
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
142 <h4 <%=heading_options%> ><a name="for">For Statement</a></h4>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
143
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
144 <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>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
145
389
497d4ef0a89f documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 387
diff changeset
146 <p><tt><pre>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
147 for i in range(from,to,step) do <i>block</i> end
389
497d4ef0a89f documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 387
diff changeset
148 </pre></tt></p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
149
468
9b51e2413cab documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 465
diff changeset
150 <p>The Luan generic <b>for</b> statement is simpler than the Lua version because Luan only uses an expression, not an explist. So a <b>for</b> statement like:</p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
151
389
497d4ef0a89f documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 387
diff changeset
152 <p><tt><pre>
390
Franklin Schmidt <fschmidt@gmail.com>
parents: 389
diff changeset
153 for var_1, &middot;&middot;&middot;, var_n in exp do block end
389
497d4ef0a89f documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 387
diff changeset
154 </pre></tt></p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
155
389
497d4ef0a89f documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 387
diff changeset
156 <p>is equivalent to the code:</p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
157
389
497d4ef0a89f documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 387
diff changeset
158 <p><tt><pre>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
159 do
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
160 local f = exp
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
161 while true do
390
Franklin Schmidt <fschmidt@gmail.com>
parents: 389
diff changeset
162 local var_1, &middot;&middot;&middot;, var_n = f()
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
163 if var_1 == nil then break end
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
164 block
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
165 end
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
166 end
389
497d4ef0a89f documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 387
diff changeset
167 </pre></tt></p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
168
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
169 <h4 <%=heading_options%> ><a name="logical">Logical Statements</a></h4>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
170
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
171 <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>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
172
389
497d4ef0a89f documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 387
diff changeset
173 <p><tt><pre>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
174 x==5 or error "x should be 5"
389
497d4ef0a89f documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 387
diff changeset
175 </pre></tt></p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
176
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
177 <h4 <%=heading_options%> ><a name="template_stmt">Template Statements</a></h4>
367
c207be7cf45d more documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 354
diff changeset
178
465
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
179 <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>
367
c207be7cf45d more documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 354
diff changeset
180
c207be7cf45d more documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 354
diff changeset
181
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
182 <h3 <%=heading_options%> ><a name="expr">Expressions</a></h3>
367
c207be7cf45d more documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 354
diff changeset
183
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
184 <h4 <%=heading_options%> ><a name="conversions">Coercions and Conversions</a></h4>
465
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
185
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
186 <p>Unlike Lua, Luan does not do automatic conversions of strings to numbers.</p>
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
187
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
188 <h4 <%=heading_options%> ><a name="bit">Bitwise Operators</a></h4>
367
c207be7cf45d more documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 354
diff changeset
189
465
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
190 <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>
367
c207be7cf45d more documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 354
diff changeset
191
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
192 <h4 <%=heading_options%> ><a name="logical_ops">Logical Operators</a></h4>
367
c207be7cf45d more documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 354
diff changeset
193
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
194 <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>
367
c207be7cf45d more documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 354
diff changeset
195
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
196 <h4 <%=heading_options%> ><a name="concatenation">Concatenation</a></h4>
465
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
197
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
198 <p>Unlike Lua, Luan converts all concatenation operands to strings.
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
199
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
200 <h4 <%=heading_options%> ><a name="fn_calls">Function Calls</a></h4>
367
c207be7cf45d more documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 354
diff changeset
201
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
202 <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>
367
c207be7cf45d more documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 354
diff changeset
203
479
1285c52ea9d4 add manual heading_options
Franklin Schmidt <fschmidt@gmail.com>
parents: 468
diff changeset
204 <h4 <%=heading_options%> ><a name="template_expr">Template Expressions</a></h4>
367
c207be7cf45d more documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 354
diff changeset
205
465
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
206 <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>
367
c207be7cf45d more documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 354
diff changeset
207
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
208 </div>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
209
391
2f5cc9c2cbf0 replace Html.simply_html_page with simply_html_head and simply_html_body_bottom
Franklin Schmidt <fschmidt@gmail.com>
parents: 390
diff changeset
210 <% Html.simply_html_body_bottom() %>
2f5cc9c2cbf0 replace Html.simply_html_page with simply_html_head and simply_html_body_bottom
Franklin Schmidt <fschmidt@gmail.com>
parents: 390
diff changeset
211 </body>
2f5cc9c2cbf0 replace Html.simply_html_page with simply_html_head and simply_html_body_bottom
Franklin Schmidt <fschmidt@gmail.com>
parents: 390
diff changeset
212 </html>
2f5cc9c2cbf0 replace Html.simply_html_page with simply_html_head and simply_html_body_bottom
Franklin Schmidt <fschmidt@gmail.com>
parents: 390
diff changeset
213 <%
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
214 end