annotate website/src/diff.html.luan @ 1830:d72a52232f79

mail - minor
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 24 Sep 2024 17:17:57 -0600
parents 50e570b598b2
children
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 %>
1813
fa0e73119b7c docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1812
diff changeset
30 <p>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>
1813
fa0e73119b7c docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1812
diff changeset
41
1814
Franklin Schmidt <fschmidt@gmail.com>
parents: 1813
diff changeset
42 <p>Luan does not have the Lua <em>thread</em> type which aren't actually threads but in fact are coroutines. Luan has real threads. This is particularly valuable for web serving where each request is handled by a thread. But thread synchronization is too complicated for application programmers. So Luan makes mutable objects immutable when they become accessible by multiple threads. This eliminates the need for thread synchronization. If there is a need to share mutable state across threads, there are special functions for this.</p>
1653
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 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
45 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
46 env = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
47 title = "Environments"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
48 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
49 %>
562
7cc9d4a53d3b remove SimplyHTML from documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 513
diff changeset
50 <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
51
1521
d3e61cd2aca0 docs and shell bug fix
Franklin Schmidt <fschmidt@gmail.com>
parents: 1520
diff changeset
52 <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
53 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
54 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
55 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
56 error = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
57 title = "Error Handling"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
58 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
59 %>
1521
d3e61cd2aca0 docs and shell bug fix
Franklin Schmidt <fschmidt@gmail.com>
parents: 1520
diff changeset
60 <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
61 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
62 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
63 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
64 meta = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
65 title = "Metatables and Metamethods"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
66 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
67 %>
465
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
68 <p>Luan only has metatable for tables, not for other types.</p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
69
685
1e4b0bc0202d update documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 604
diff changeset
70 <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
71 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
72 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
73 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
74 gc = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
75 title = "Garbage Collection"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
76 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
77 %>
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
78 <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
79
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
80 <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
81 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
82 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
83 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
84 coroutines = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
85 title = "Coroutines"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
86 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
87 %>
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
88 <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
89 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
90 end
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 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
93 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
94 lang = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
95 title = "The Language"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
96 subs = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
97 lex = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
98 title = "Lexical Conventions"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
99 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
100 %>
685
1e4b0bc0202d update documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 604
diff changeset
101 <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
102
1660
2968e43cdd44 manual work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1653
diff changeset
103 <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
104 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
105 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
106 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
107 vars = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
108 title = "Variables"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
109 content = function()
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 <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
112 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
113 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
114 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
115 stmt = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
116 title = "Statements"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
117 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
118 %>
1521
d3e61cd2aca0 docs and shell bug fix
Franklin Schmidt <fschmidt@gmail.com>
parents: 1520
diff changeset
119 <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
120
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
121 <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
122 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
123 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
124 subs = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
125 control = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
126 title = "Control Structures"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
127 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
128 %>
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
129 <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
130
1645
0af6a9d6d12f minor - keywords
Franklin Schmidt <fschmidt@gmail.com>
parents: 1521
diff changeset
131 <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
132
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
133 <p>Luan does not have a <b>goto</b> statement.</p>
1653
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 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
136 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
137 ["for"] = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
138 title = "For Statement"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
139 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
140 %>
562
7cc9d4a53d3b remove SimplyHTML from documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 513
diff changeset
141 <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
142
1812
f44dcb3fedf7 docs - add code block
Franklin Schmidt <fschmidt@gmail.com>
parents: 1797
diff changeset
143 <code block>
f44dcb3fedf7 docs - add code block
Franklin Schmidt <fschmidt@gmail.com>
parents: 1797
diff changeset
144 for i in range(from,to,step) do <em>block</em> end
f44dcb3fedf7 docs - add code block
Franklin Schmidt <fschmidt@gmail.com>
parents: 1797
diff changeset
145 </code>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
146
468
9b51e2413cab documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 465
diff changeset
147 <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
148
1812
f44dcb3fedf7 docs - add code block
Franklin Schmidt <fschmidt@gmail.com>
parents: 1797
diff changeset
149 <code block>
f44dcb3fedf7 docs - add code block
Franklin Schmidt <fschmidt@gmail.com>
parents: 1797
diff changeset
150 for var_1, &middot;&middot;&middot;, var_n in exp do block end
f44dcb3fedf7 docs - add code block
Franklin Schmidt <fschmidt@gmail.com>
parents: 1797
diff changeset
151 </code>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
152
389
497d4ef0a89f documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 387
diff changeset
153 <p>is equivalent to the code:</p>
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
154
1812
f44dcb3fedf7 docs - add code block
Franklin Schmidt <fschmidt@gmail.com>
parents: 1797
diff changeset
155 <code block>
f44dcb3fedf7 docs - add code block
Franklin Schmidt <fschmidt@gmail.com>
parents: 1797
diff changeset
156 do
f44dcb3fedf7 docs - add code block
Franklin Schmidt <fschmidt@gmail.com>
parents: 1797
diff changeset
157 local f = exp
f44dcb3fedf7 docs - add code block
Franklin Schmidt <fschmidt@gmail.com>
parents: 1797
diff changeset
158 while true do
f44dcb3fedf7 docs - add code block
Franklin Schmidt <fschmidt@gmail.com>
parents: 1797
diff changeset
159 local var_1, &middot;&middot;&middot;, var_n = f()
f44dcb3fedf7 docs - add code block
Franklin Schmidt <fschmidt@gmail.com>
parents: 1797
diff changeset
160 if var_1 == nil then break end
f44dcb3fedf7 docs - add code block
Franklin Schmidt <fschmidt@gmail.com>
parents: 1797
diff changeset
161 block
353
38c19ecc384d start documentation
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
162 end
1812
f44dcb3fedf7 docs - add code block
Franklin Schmidt <fschmidt@gmail.com>
parents: 1797
diff changeset
163 end
f44dcb3fedf7 docs - add code block
Franklin Schmidt <fschmidt@gmail.com>
parents: 1797
diff changeset
164 </code>
1653
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 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
167 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
168 ["try"] = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
169 title = "Try Statement"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
170 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
171 %>
1520
d9a5405a3102 try statement
Franklin Schmidt <fschmidt@gmail.com>
parents: 1384
diff changeset
172 <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
173 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
174 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
175 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
176 logical = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
177 title = "Logical Statements"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
178 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
179 %>
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
180 <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
181
1812
f44dcb3fedf7 docs - add code block
Franklin Schmidt <fschmidt@gmail.com>
parents: 1797
diff changeset
182 <code block>
f44dcb3fedf7 docs - add code block
Franklin Schmidt <fschmidt@gmail.com>
parents: 1797
diff changeset
183 x==5 or error "x should be 5"
f44dcb3fedf7 docs - add code block
Franklin Schmidt <fschmidt@gmail.com>
parents: 1797
diff changeset
184 </code>
1653
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 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
187 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
188 template_stmt = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
189 title = "Template Statements"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
190 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
191 %>
465
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
192 <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
193 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
194 end
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 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
197 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
198 expr = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
199 title = "Expressions"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
200 subs = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
201 conversions = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
202 title = "Coercions and Conversions"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
203 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
204 %>
465
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
205 <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
206 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
207 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
208 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
209 bit = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
210 title = "Bitwise Operators"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
211 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
212 %>
465
47c7de1f2322 documentation work
Franklin Schmidt <fschmidt@gmail.com>
parents: 464
diff changeset
213 <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
214 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
215 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
216 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
217 logical_ops = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
218 title = "Logical Operators"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
219 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
220 %>
386
db23f654f87d make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 372
diff changeset
221 <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
222 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
223 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
224 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
225 concatenation = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
226 title = "Concatenation"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
227 content = function()
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 <p>Unlike Lua, Luan converts all concatenation operands to strings.</p>
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 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
232 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
233 constructors = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
234 title = "Table Constructors"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
235 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
236 %>
686
33f1b4ad2c9d more documentation fixes
Franklin Schmidt <fschmidt@gmail.com>
parents: 685
diff changeset
237 <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
238 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
239 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
240 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
241 fn_calls = {
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
242 title = "Function Calls"
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
243 content = function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
244 %>
1090
616761e0b9f6 update documentation for last change
Franklin Schmidt <fschmidt@gmail.com>
parents: 693
diff changeset
245 <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
246
562
7cc9d4a53d3b remove SimplyHTML from documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 513
diff changeset
247 <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
248
685
1e4b0bc0202d update documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 604
diff changeset
249 <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
250 <%
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
251 end
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
252 }
1797
ba43135bb98d backticks docs
Franklin Schmidt <fschmidt@gmail.com>
parents: 1660
diff changeset
253 backticks = {
ba43135bb98d backticks docs
Franklin Schmidt <fschmidt@gmail.com>
parents: 1660
diff changeset
254 title = "Backticks"
ba43135bb98d backticks docs
Franklin Schmidt <fschmidt@gmail.com>
parents: 1660
diff changeset
255 content = function()
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 <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
258 <%
ba43135bb98d backticks docs
Franklin Schmidt <fschmidt@gmail.com>
parents: 1660
diff changeset
259 end
ba43135bb98d backticks docs
Franklin Schmidt <fschmidt@gmail.com>
parents: 1660
diff changeset
260 }
1653
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 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
264 }
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
265 }
685
1e4b0bc0202d update documentation
Franklin Schmidt <fschmidt@gmail.com>
parents: 604
diff changeset
266
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
267
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
268 return function()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
269 Io.stdout = Http.response.text_writer()
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
270 %>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
271 <!doctype html>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
272 <html>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
273 <head>
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 <title>How Luan differs from Lua</title>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
276 </head>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
277 <body>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
278 <% docs_header() %>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
279 <div content>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
280 <h1><a href="diff.html">How Luan differs from Lua</a></h1>
1827
50e570b598b2 security
Franklin Schmidt <fschmidt@gmail.com>
parents: 1814
diff changeset
281 <p>This document explains how Luan differs from <a href="https://www.lua.org/">Lua</a> as described in the <a href="https://www.lua.org/manual/5.3/">Lua 5.3 Reference Manual</a>.</p>
1653
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
282 <hr>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
283 <h2>Contents</h2>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
284 <div toc>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
285 <% show_toc(content) %>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
286 </div>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
287 <hr>
418b610e887b docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1652
diff changeset
288 <% show_content(content,2) %>
1651
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1645
diff changeset
289 </div>
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1645
diff changeset
290 </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
291 </html>
1651
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1645
diff changeset
292 <%
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1645
diff changeset
293 end