Mercurial Hosting > luan
comparison website/src/diff.html.luan @ 1929:31f006c64782
translation
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 01 May 2025 18:31:05 -0600 |
parents | 50e570b598b2 |
children |
comparison
equal
deleted
inserted
replaced
1928:e16f38f4fdfc | 1929:31f006c64782 |
---|---|
1 local Luan = require "luan:Luan.luan" | 1 local Luan = require "luan:Luan.luan" |
2 local error = Luan.error | 2 local error = Luan.error |
3 local Io = require "luan:Io.luan" | 3 local Io = require "luan:Io.luan" |
4 local Http = require "luan:http/Http.luan" | 4 local Site_translator = require "luan:gpt/Site_translator.luan" |
5 local get_lang = Site_translator.get_lang or error() | |
6 local text_writer = Site_translator.text_writer or error() | |
5 local Shared = require "site:/lib/Shared.luan" | 7 local Shared = require "site:/lib/Shared.luan" |
6 local head = Shared.head or error() | 8 local head = Shared.head or error() |
7 local docs_header = Shared.docs_header or error() | 9 local docs_header = Shared.docs_header or error() |
8 local show_toc = Shared.show_toc or error() | 10 local show_toc = Shared.show_toc or error() |
9 local show_content = Shared.show_content or error() | 11 local show_content = Shared.show_content or error() |
25 subs = { | 27 subs = { |
26 types = { | 28 types = { |
27 title = "Values and Types" | 29 title = "Values and Types" |
28 content = function() | 30 content = function() |
29 %> | 31 %> |
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> | 32 <p>Luan adds a <b>binary</b> type that Lua doesn't have. This is because Lua strings can represent binary while Luan strings cannot.</p> |
31 | 33 |
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> | 34 <p>The Luan <b>Nil</b> type is implemented as the Java <b>null</b>. The Luan <b>Boolean</b> type is implemented as the Java <b>Boolean</b> type. The Luan <b>Number</b> type is implemented as the Java <b>Number</b> type. The Luan <b>String</b> type is implemented as the Java <b>String</b> type. Actual numbers may be any subclass of the Java <b>Number</b> class.</p> |
33 | 35 |
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> | 36 <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> |
35 | 37 |
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> | 38 <p>The Luan <b>java</b> type is a replacement for Lua's <b>userdata</b>. A Luan <b>java</b> value is nothing more than a Java object that doesn't fall into one of the other recognized types.</p> |
37 | 39 |
38 <p>The Luan <em>binary</em> type is the Java <em>byte[ ]</em> type which is an array of bytes.</p> | 40 <p>The Luan <b>binary</b> type is the Java <b>byte[ ]</b> type which is an array of bytes.</p> |
39 | 41 |
40 <p>The Luan <em>table</em> type is just like its Lua equivalent, but implemented in Java.</p> | 42 <p>The Luan <b>table</b> type is just like its Lua equivalent, but implemented in Java.</p> |
41 | 43 |
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> | 44 <p>Luan does not have the Lua <b>thread</b> 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> |
43 <% | 45 <% |
44 end | 46 end |
45 } | 47 } |
46 env = { | 48 env = { |
47 title = "Environments" | 49 title = "Environments" |
139 content = function() | 141 content = function() |
140 %> | 142 %> |
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> | 143 <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> |
142 | 144 |
143 <code block> | 145 <code block> |
144 for i in range(from,to,step) do <em>block</em> end | 146 for i in range(from,to,step) do block end |
145 </code> | 147 </code> |
146 | 148 |
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> | 149 <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> |
148 | 150 |
149 <code block> | 151 <code block> |
244 %> | 246 %> |
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> | 247 <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> |
246 | 248 |
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> | 249 <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> |
248 | 250 |
249 <p>Luan doesn't support <em>proper tail calls</em>. Because Java doesn't support this cleanly, this was left out.</p> | 251 <p>Luan doesn't support <b>proper tail calls</b>. Because Java doesn't support this cleanly, this was left out.</p> |
250 <% | 252 <% |
251 end | 253 end |
252 } | 254 } |
253 backticks = { | 255 backticks = { |
254 title = "Backticks" | 256 title = "Backticks" |
264 } | 266 } |
265 } | 267 } |
266 | 268 |
267 | 269 |
268 return function() | 270 return function() |
269 Io.stdout = Http.response.text_writer() | 271 Io.stdout = text_writer() |
270 %> | 272 %> |
271 <!doctype html> | 273 <!doctype html> |
272 <html> | 274 <html lang="<%=get_lang()%>"> |
273 <head> | 275 <head> |
274 <% head() %> | 276 <% head() %> |
275 <title>How Luan differs from Lua</title> | 277 <title>How Luan differs from Lua</title> |
276 </head> | 278 </head> |
277 <body> | 279 <body> |