Mercurial Hosting > luan
annotate website/src/diff.html.luan @ 450:4b8281c5c5af
add web/test
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 04 May 2015 23:40:52 -0600 |
parents | 2f5cc9c2cbf0 |
children | eddf7c73373b |
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" |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
3 local Http = require "luan:web/Http" |
387
23d075ce1e48
add website/src/Shared.luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
386
diff
changeset
|
4 local Shared = require "site:/Shared" |
353 | 5 |
6 | |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
7 function service() |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
8 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
|
9 %> |
2f5cc9c2cbf0
replace Html.simply_html_page with simply_html_head and simply_html_body_bottom
Franklin Schmidt <fschmidt@gmail.com>
parents:
390
diff
changeset
|
10 <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
|
11 <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
|
12 <% 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
|
13 <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
|
14 </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 <body> |
353 | 16 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
17 <div container> |
387
23d075ce1e48
add website/src/Shared.luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
386
diff
changeset
|
18 <% Shared.header() %> |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
19 <h1>How Luan differs from Lua</h1> |
353 | 20 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
21 <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 | 22 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
23 <hr/> |
353 | 24 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
25 <h2>Contents</h2> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
26 |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
27 <div margin-bottom="1em"><a href="#intro">Introduction</a></div> |
353 | 28 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
29 <div margin-bottom="1em"> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
30 <a href="#basic">Basic Concepts</a> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
31 <ul> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
32 <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
|
33 <li><a href="#env">Environments</a></li> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
34 <li><a href="#error">Error Handling</a></li> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
35 <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
|
36 <li><a href="#gc">Garbage Collection</a></li> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
37 <li><a href="#coroutines">Coroutines</a></li> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
38 </ul> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
39 </div> |
353 | 40 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
41 <div margin-bottom="1em"> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
42 <a href="#lang">The Language</a> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
43 <ul> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
44 <li><a href="#lex">Lexical Conventions</a></li> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
45 <li> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
46 <a href="#stmt">Statements</a> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
47 <ul> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
48 <li><a href="#control">Control Structures</a></li> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
49 <li><a href="#for">For Statement</a></li> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
50 <li><a href="#logical">Logical Statements</a></li> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
51 <li><a href="#template-stmt">Template Statements</a></li> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
52 </ul> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
53 </li> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
54 <li> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
55 <a href="#expr">Expressions</a> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
56 <ul> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
57 <li><a href="#bit">Bitwise Operators</a></li> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
58 <li><a href="#local-ops">Logical Operators</a></li> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
59 <li><a href="#fn-call">Function Calls</a></li> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
60 <li><a href="#template-expr">Template Expressions</a></li> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
61 </ul> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
62 </li> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
63 </ul> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
64 </div> |
353 | 65 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
66 <hr/> |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
67 |
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
68 <h2 margin-top="1em"><a name="intro">Introduction</a></h2> |
372 | 69 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
70 <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 | 71 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
72 <p>Luan is implemented in Java and is tightly integrated with Java. This makes it an excellent scripting language for Java.</p> |
353 | 73 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
74 <h2 margin-top="1em"><a name="basic">Basic Concepts</a></h2> |
353 | 75 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
76 <h3 margin-top="1em"><a name="types">Values and Types</a></h3> |
353 | 77 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
78 <p>Luan does not have the Lua <i>thread</i> type. Luan add a <i>binary</i> type that Lua doesn't have. This is because Lua strings can represent binary while Luan strings cannot.</p> |
353 | 79 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
80 <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 | 81 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
82 <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 | 83 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
84 <p>Luan <i>userdata</i> is nothing more than a Java object that doesn't fall into one of the other recognized types.</p> |
353 | 85 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
86 <p>The Luan <i>binary</i> type is the Java <i>byte[ ]</i> type which is an array of bytes.</p> |
353 | 87 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
88 <p>The Luan <i>table</i> type is just like its Lua equivalent, but implemented in Java.</p> |
353 | 89 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
90 <h3 margin-top="1em"><a name="env">Environments</a></h3> |
353 | 91 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
92 <p>Luan has an <tt>_ENV</tt> which is like its Lua equivalent. However Luan has no global environment at all, no <tt>_G</tt>.</p> |
353 | 93 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
94 <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 | 95 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
96 <h3 margin-top="1em"><a name="error">Error Handling</a></h3> |
353 | 97 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
98 <p>Luan has the functions <tt>error</tt> and <tt>pcall</tt> but does not have <tt>xpcall</tt>. Luan adds the function <tt>try</tt> which looks and acts like try-catch blocks in other languages.</p> |
353 | 99 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
100 <h3 margin-top="1em"><a name="meta">Metatables and Metamethods</a></h3> |
353 | 101 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
102 <p>to document later...</p> |
353 | 103 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
104 <h3 margin-top="1em"><a name="gc">Garbage Collection</a></h3> |
353 | 105 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
106 <p>Luan uses Java garbage collection. Luan has no special garbage collection methods.</p> |
353 | 107 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
108 <p>Luan does not yet have weak tables but this will be added.</p> |
353 | 109 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
110 <h3 margin-top="1em"><a name="coroutines">Coroutines</a></h3> |
353 | 111 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
112 <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 | 113 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
114 <h2 margin-top="1em"><a name="lang">The Language</a></h2> |
353 | 115 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
116 <h3 margin-top="1em"><a name="lex">Lexical Conventions</a></h3> |
353 | 117 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
118 <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 | 119 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
120 <p>Luan has exactly the same set of keywords as Lua and has the same other lexical conventions.</p> |
353 | 121 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
122 <h3 margin-top="1em"><a name="stmt">Statements</a></h3> |
353 | 123 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
124 <p>Most statements in Luan are the same as Lua. Only those statements that differ will be listed here.</p> |
353 | 125 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
126 <h4 margin-top="1em"><a name="control">Control Structures</a></h4> |
353 | 127 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
128 <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 | 129 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
130 <p>Luan does not have a <b>goto</b> statement.</p> |
353 | 131 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
132 <h4 margin-top="1em"><a name="for">For Statement</a></h4> |
353 | 133 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
134 <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 | 135 |
389 | 136 <p><tt><pre> |
353 | 137 for i in range(from,to,step) do <i>block</i> end |
389 | 138 </pre></tt></p> |
353 | 139 |
389 | 140 <p>The Luan generic <b>for</b> statement is simpler than the Lua version because Luan only uses and expression, not an explist. So a <b>for</b> statement like:</p> |
353 | 141 |
389 | 142 <p><tt><pre> |
390 | 143 for var_1, ···, var_n in exp do block end |
389 | 144 </pre></tt></p> |
353 | 145 |
389 | 146 <p>is equivalent to the code:</p> |
353 | 147 |
389 | 148 <p><tt><pre> |
353 | 149 do |
150 local f = exp | |
151 while true do | |
390 | 152 local var_1, ···, var_n = f() |
353 | 153 if var_1 == nil then break end |
154 block | |
155 end | |
156 end | |
389 | 157 </pre></tt></p> |
353 | 158 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
159 <h4 margin-top="1em"><a name="logical">Logical Statements</a></h4> |
353 | 160 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
161 <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 | 162 |
389 | 163 <p><tt><pre> |
353 | 164 x==5 or error "x should be 5" |
389 | 165 </pre></tt></p> |
353 | 166 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
167 <h4 margin-top="1em"><a name="template-stmt">Template Statements</a></h4> |
367 | 168 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
169 <p>Template statements are based on <a href="#template-expr">template exressions</a> and provide the full equivalent of <a href="http://en.wikipedia.org/wiki/JavaServer_Pages">JSP</a> but in a general way. Template statements write the equivalent template exression to standard output. For example:</p> |
367 | 170 |
389 | 171 <p><tt><pre><%=Html.encode[[ |
367 | 172 local name = "Bob" |
173 %> | |
174 Hello <%=name%>! | |
175 Bye <%=name%>. | |
176 <% | |
389 | 177 ]]%></pre></tt></p> |
367 | 178 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
179 <p>is equivalent to the code:</p> |
367 | 180 |
389 | 181 <p><tt><pre><%=Html.encode[[ |
367 | 182 local name = "Bob" |
370 | 183 require("luan:Io").stdout.write( %> |
367 | 184 Hello <%=name%>! |
185 Bye <%=name%>. | |
186 <% ) | |
389 | 187 ]]%></pre></tt></p> |
367 | 188 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
189 <h3 margin-top="1em"><a name="expr">Expressions</a></h3> |
367 | 190 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
191 <h4 margin-top="1em"><a name="bit">Bitwise Operators</a></h4> |
367 | 192 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
193 <p>Bitwise operators appear to be new addition to Lua 5.3 and didn't exist in Lua 5.2. Luan does not support bitwise operators, but these can be added if there is a need.</p> |
367 | 194 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
195 <h4 margin-top="1em"><a name="local-ops">Logical Operators</a></h4> |
367 | 196 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
197 <p>The only change in Luan is that <b>not</b> must take a boolean argument. This helps catch errors and makes code more readable.</p> |
367 | 198 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
199 <h4 margin-top="1em"><a name="fn-call">Function Calls</a></h4> |
367 | 200 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
201 <p>Luan does not support Lua's <tt>v:name(args)</tt> style object-oriented function call. Object oriented programming is done in Luan using closures, so this feature is not needed.</p> |
367 | 202 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
203 <h4 margin-top="1em"><a name="template-expr">Template Expressions</a></h4> |
367 | 204 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
205 <p>Luan adds a new type of expression based on <a href="http://en.wikipedia.org/wiki/JavaServer_Pages">JSP</a> called template expressions. Template expressions return multiple values. Here is an example:</p> |
367 | 206 |
389 | 207 <p><tt><pre><%=Html.encode[[ |
367 | 208 local name = "Bob" |
209 write( %>Hello <%=name%>!<% ) | |
389 | 210 ]]%></pre></tt></p> |
367 | 211 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
212 <p>This is equivalent to the code:</p> |
370 | 213 |
389 | 214 <p><tt><pre> |
370 | 215 local name = "Bob" |
216 write( "Hello ", name, "!" ) | |
389 | 217 </pre></tt></p> |
370 | 218 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
219 <p>The strings in template expressions may be multiple lines.</p> |
367 | 220 |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
221 </div> |
353 | 222 |
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
|
223 <% 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
|
224 </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
|
225 </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
|
226 <% |
386
db23f654f87d
make all of website use luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
372
diff
changeset
|
227 end |