annotate website/src/diff.html.luan @ 1805:7793bcb5f34a

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 08 May 2024 11:13:16 -0600
parents ba43135bb98d
children f44dcb3fedf7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1651
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1645
diff changeset
1 local Luan = require "luan:Luan.luan"
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1645
diff changeset
2 local error = Luan.error
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1645
diff changeset
3 local Io = require "luan:Io.luan"
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1645
diff changeset
4 local Http = require "luan:http/Http.luan"
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1645
diff changeset
5 local Shared = require "site:/lib/Shared.luan"
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1645
diff changeset
6 local head = Shared.head or error()
1652
d5779a264a4a docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1651
diff changeset
7 local docs_header = Shared.docs_header or error()
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
8 local show_toc = Shared.show_toc or error()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
9 local show_content = Shared.show_content or error()
1651
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1645
diff changeset
10
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1645
diff changeset
11
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
12 local content = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
13 intro = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
14 title = "Introduction"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
15 content = function()
1651
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1645
diff changeset
16 %>
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
17 <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
18
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
19 <p>Luan is implemented in Java and is tightly integrated with Java. This makes it an excellent scripting language for Java.</p>
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
20 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
21 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
22 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
23 basic = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
24 title = "Basic Concepts"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
25 subs = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
26 types = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
27 title = "Values and Types"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
28 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
29 %>
562
7cc9d4a53d3b remove SimplyHTML from documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 513
diff changeset
30 <p>Luan does not have the Lua <em>thread</em> type. Luan adds a <em>binary</em> 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
31
562
7cc9d4a53d3b remove SimplyHTML from documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 513
diff changeset
32 <p>The Luan <em>Nil</em> type is implemented as the Java <em>null</em>. The Luan <em>Boolean</em> type is implemented as the Java <em>Boolean</em> type. The Luan <em>Number</em> type is implemented as the Java <em>Number</em> type. The Luan <em>String</em> type is implemented as the Java <em>String</em> type. Actual numbers may be any subclass of the Java <em>Number</em> class.</p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
34 <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
35
562
7cc9d4a53d3b remove SimplyHTML from documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 513
diff changeset
36 <p>The Luan <em>java</em> type is a replacement for Lua's <em>userdata</em>. A Luan <em>java</em> 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
37
562
7cc9d4a53d3b remove SimplyHTML from documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 513
diff changeset
38 <p>The Luan <em>binary</em> type is the Java <em>byte[ ]</em> type which is an array of bytes.</p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39
562
7cc9d4a53d3b remove SimplyHTML from documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 513
diff changeset
40 <p>The Luan <em>table</em> type is just like its Lua equivalent, but implemented in Java.</p>
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
41 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
42 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
43 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
44 env = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
45 title = "Environments"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
46 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
47 %>
562
7cc9d4a53d3b remove SimplyHTML from documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 513
diff changeset
48 <p>Luan has no global environment at all, no <code>_G</code>. By default, Luan doesn't define <code>_ENV</code> either, but if you define it as a local table in a chunk, then it acts like it does in Lua. When <code>_ENV</code> 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
49
1521
d3e61cd2aca0 docs and shell bug fix
Franklin Schmidt <fschmidt@gmail.com>
parents: 1520
diff changeset
50 <p>Every module is initialized with one local function: <code>require</code>. The module then uses this function to get access to whatever else it needs.</p>
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
51 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
52 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
53 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
54 error = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
55 title = "Error Handling"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
56 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
57 %>
1521
d3e61cd2aca0 docs and shell bug fix
Franklin Schmidt <fschmidt@gmail.com>
parents: 1520
diff changeset
58 <p>Luan has the function <code>error</code> but does not have <code>pcall</code> or <code>xpcall</code>. Luan adds the <a href="#try">try statement</a> instead. Luan errors are implemented as an error table, not as a message object.</p>
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
59 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
60 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
61 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
62 meta = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
63 title = "Metatables and Metamethods"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
64 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
65 %>
465
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
66 <p>Luan only has metatable for tables, not for other types.</p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
67
685
1e4b0bc0202d update documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 604
diff changeset
68 <p>Luan does not support the <b>call</b> metamethod. There is nothing that one can do with the <b>call</b> metamethod that can't be done more cleanly with closures, so this was left out.</p>
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
69 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
70 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
71 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
72 gc = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
73 title = "Garbage Collection"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
74 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
75 %>
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
76 <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
77
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
78 <p>Luan does not yet have weak tables but this will be added.</p>
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
79 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
80 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
81 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
82 coroutines = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
83 title = "Coroutines"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
84 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
85 %>
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
86 <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>
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
87 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
88 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
89 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
90 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
91 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
92 lang = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
93 title = "The Language"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
94 subs = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
95 lex = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
96 title = "Lexical Conventions"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
97 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
98 %>
685
1e4b0bc0202d update documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 604
diff changeset
99 <p>Unlike Lua, Luan considers the end of a line to be the end of a statement. This catches errors and encourages readability. If you want to continue a statement on another line, you can use a backslash followed by a newline which will be treated as white space.</p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
100
1660
2968e43cdd44 manual work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1653
diff changeset
101 <p>Luan has a similar set of keywords to Lua and has the same other lexical conventions.</p>
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
102 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
103 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
104 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
105 vars = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
106 title = "Variables"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
107 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
108 %>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
109 <p>By default, there are no global variables and an undefined variable produces a compile error. To enable global variables, one must define <code>_ENV</code>. Avoiding global variables makes it much easier to catch errors at compile time.</p>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
110 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
111 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
112 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
113 stmt = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
114 title = "Statements"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
115 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
116 %>
1521
d3e61cd2aca0 docs and shell bug fix
Franklin Schmidt <fschmidt@gmail.com>
parents: 1520
diff changeset
117 <p>Luan adds the block terminators <b>end_do</b>, <b>end_for</b>, <b>end_function</b>, <b>end_if</b>, <b>end_try</b>, and <b>end_while</b>. These can be used to end the appropriate block type, but <b>end</b> can also be used to end any block.</p>
1092
a26fbde7ee28 documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 1090
diff changeset
118
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
119 <p>Most statements in Luan are the same as Lua. Only those statements that differ will be listed here.</p>
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
120 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
121 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
122 subs = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
123 control = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
124 title = "Control Structures"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
125 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
126 %>
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
127 <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
128
1645
0af6a9d6d12f minor - keywords
Franklin Schmidt <fschmidt@gmail.com>
parents: 1521
diff changeset
129 <p>Luan adds the <b>continue</b> statement which is used inside loops.</p>
0af6a9d6d12f minor - keywords
Franklin Schmidt <fschmidt@gmail.com>
parents: 1521
diff changeset
130
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
131 <p>Luan does not have a <b>goto</b> statement.</p>
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
132 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
133 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
134 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
135 ["for"] = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
136 title = "For Statement"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
137 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
138 %>
562
7cc9d4a53d3b remove SimplyHTML from documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 513
diff changeset
139 <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 <code>range</code> function in a generic <b>for</b> statement like this:</p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
140
562
7cc9d4a53d3b remove SimplyHTML from documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 513
diff changeset
141 <pre>
7cc9d4a53d3b remove SimplyHTML from documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 513
diff changeset
142 for i in range(from,to,step) do <em>block</em> end
7cc9d4a53d3b remove SimplyHTML from documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 513
diff changeset
143 </pre>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
144
468
9b51e2413cab documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 465
diff changeset
145 <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
146
562
7cc9d4a53d3b remove SimplyHTML from documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 513
diff changeset
147 <pre>
390
Franklin Schmidt <fschmidt@gmail.com>
parents: 389
diff changeset
148 for var_1, &middot;&middot;&middot;, var_n in exp do block end
562
7cc9d4a53d3b remove SimplyHTML from documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 513
diff changeset
149 </pre>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
150
389
497d4ef0a89f documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 387
diff changeset
151 <p>is equivalent to the code:</p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
152
562
7cc9d4a53d3b remove SimplyHTML from documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 513
diff changeset
153 <pre>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
154 do
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
155 local f = exp
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
156 while true do
390
Franklin Schmidt <fschmidt@gmail.com>
parents: 389
diff changeset
157 local var_1, &middot;&middot;&middot;, var_n = f()
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
158 if var_1 == nil then break end
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
159 block
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
160 end
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
161 end
562
7cc9d4a53d3b remove SimplyHTML from documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 513
diff changeset
162 </pre>
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
163 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
164 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
165 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
166 ["try"] = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
167 title = "Try Statement"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
168 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
169 %>
1520
d9a5405a3102 try statement
Franklin Schmidt <fschmidt@gmail.com>
parents: 1384
diff changeset
170 <p>Unlike Lua, Luan has a <b>try</b> statement. See <a href="manual.html#try">Try Statement</a> in the Luan Reference Manual. This also eliminates the need for Lua's <b>pcall</b> function which Luan doesn't have.</p>
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
171 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
172 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
173 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
174 logical = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
175 title = "Logical Statements"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
176 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
177 %>
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
178 <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
179
562
7cc9d4a53d3b remove SimplyHTML from documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 513
diff changeset
180 <pre>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
181 x==5 or error "x should be 5"
562
7cc9d4a53d3b remove SimplyHTML from documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 513
diff changeset
182 </pre>
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
183 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
184 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
185 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
186 template_stmt = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
187 title = "Template Statements"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
188 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
189 %>
465
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
190 <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>
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
191 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
192 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
193 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
194 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
195 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
196 expr = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
197 title = "Expressions"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
198 subs = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
199 conversions = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
200 title = "Coercions and Conversions"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
201 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
202 %>
465
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
203 <p>Unlike Lua, Luan does not do automatic conversions of strings to numbers.</p>
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
204 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
205 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
206 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
207 bit = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
208 title = "Bitwise Operators"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
209 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
210 %>
465
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
211 <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>
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
212 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
213 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
214 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
215 logical_ops = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
216 title = "Logical Operators"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
217 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
218 %>
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
219 <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>
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
220 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
221 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
222 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
223 concatenation = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
224 title = "Concatenation"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
225 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
226 %>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
227 <p>Unlike Lua, Luan converts all concatenation operands to strings.</p>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
228 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
229 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
230 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
231 constructors = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
232 title = "Table Constructors"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
233 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
234 %>
686
33f1b4ad2c9d more documentation fixes
Franklin Schmidt <fschmidt@gmail.com>
parents: 685
diff changeset
235 <p>Unlike Lua, Luan considers an <b>end_of_line</b> to be a field separator in a table constructor.</p>
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
236 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
237 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
238 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
239 fn_calls = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
240 title = "Function Calls"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
241 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
242 %>
1090
616761e0b9f6 update documentation for last change
Franklin Schmidt <fschmidt@gmail.com>
parents: 693
diff changeset
243 <p>Unlike Lua, Luan does not allow extra non-nil arguments to be passed to a function. In Luan, this causes an error. This change helps find coding mistakes that would be very hard to detect otherwise.</p>
616761e0b9f6 update documentation for last change
Franklin Schmidt <fschmidt@gmail.com>
parents: 693
diff changeset
244
562
7cc9d4a53d3b remove SimplyHTML from documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 513
diff changeset
245 <p>Luan does not support Lua's <code>v:name(args)</code> 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
246
685
1e4b0bc0202d update documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 604
diff changeset
247 <p>Luan doesn't support <em>proper tail calls</em>. Because Java doesn't support this cleanly, this was left out.</p>
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
248 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
249 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
250 }
1797
ba43135bb98d backticks docs
Franklin Schmidt <fschmidt@gmail.com>
parents: 1660
diff changeset
251 backticks = {
ba43135bb98d backticks docs
Franklin Schmidt <fschmidt@gmail.com>
parents: 1660
diff changeset
252 title = "Backticks"
ba43135bb98d backticks docs
Franklin Schmidt <fschmidt@gmail.com>
parents: 1660
diff changeset
253 content = function()
ba43135bb98d backticks docs
Franklin Schmidt <fschmidt@gmail.com>
parents: 1660
diff changeset
254 %>
ba43135bb98d backticks docs
Franklin Schmidt <fschmidt@gmail.com>
parents: 1660
diff changeset
255 <p>Backtick expressions are a Luan addition that don't exist in Lua. See <a href="manual.html#backticks">Backticks</a> in the Luan Reference Manual.</p>
ba43135bb98d backticks docs
Franklin Schmidt <fschmidt@gmail.com>
parents: 1660
diff changeset
256 <%
ba43135bb98d backticks docs
Franklin Schmidt <fschmidt@gmail.com>
parents: 1660
diff changeset
257 end
ba43135bb98d backticks docs
Franklin Schmidt <fschmidt@gmail.com>
parents: 1660
diff changeset
258 }
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
259 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
260 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
261 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
262 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
263 }
685
1e4b0bc0202d update documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 604
diff changeset
264
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
265
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
266 return function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
267 Io.stdout = Http.response.text_writer()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
268 %>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
269 <!doctype html>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
270 <html>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
271 <head>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
272 <% head() %>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
273 <title>How Luan differs from Lua</title>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
274 </head>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
275 <body>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
276 <% docs_header() %>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
277 <div content>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
278 <h1><a href="diff.html">How Luan differs from Lua</a></h1>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
279 <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>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
280 <hr>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
281 <h2>Contents</h2>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
282 <div toc>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
283 <% show_toc(content) %>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
284 </div>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
285 <hr>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
286 <% show_content(content,2) %>
1651
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1645
diff changeset
287 </div>
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1645
diff changeset
288 </body>
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
289 </html>
1651
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1645
diff changeset
290 <%
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1645
diff changeset
291 end