changeset 1813:fa0e73119b7c

docs work
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 10 Jun 2024 23:19:40 -0600
parents f44dcb3fedf7
children 0ead5c6b07b0
files website/src/diff.html.luan website/src/manual.html.luan
diffstat 2 files changed, 73 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/website/src/diff.html.luan	Mon Jun 10 14:41:48 2024 -0600
+++ b/website/src/diff.html.luan	Mon Jun 10 23:19:40 2024 -0600
@@ -27,7 +27,7 @@
 				title = "Values and Types"
 				content = function()
 %>
-<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>
+<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>
 
 <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>
 
@@ -38,6 +38,8 @@
 <p>The Luan <em>binary</em> type is the Java <em>byte[ ]</em> type which is an array of bytes.</p>
 
 <p>The Luan <em>table</em> type is just like its Lua equivalent, but implemented in Java.</p>
+
+<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 objects (tables) 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 thread-local functions for this.</p>
 <%
 				end
 			}
--- a/website/src/manual.html.luan	Mon Jun 10 14:41:48 2024 -0600
+++ b/website/src/manual.html.luan	Mon Jun 10 23:19:40 2024 -0600
@@ -1984,6 +1984,31 @@
 <%
 				end
 				subs = {
+					["Luan.arg"] = {
+						title = "Luan.arg"
+						content = function()
+%>
+<p>If Luan was run from the command line then this is a list of the command line arguments.  For example if one runs Luan like this:</p>
+
+<code block>
+luan t.luan a b c
+</code>
+
+<p>Then Luan.arg will contain:</p>
+
+<code block>
+{
+	[0] = "t.luan"
+	[1] = "a"
+	[2] = "b"
+	[3] = "c"
+}
+</code>
+
+<p>And of course <code>#Luan.arg</code> will be <code>3</code>.</p>
+<%
+						end
+					}
 					["Luan.do_file"] = {
 						title = "Luan.do_file ([uri])"
 						content = function()
@@ -2180,6 +2205,38 @@
 <%
 						end
 					}
+					["Luan.parse"] = {
+						title = "Luan.parse (s)"
+						content = function()
+%>
+<p>This Luan's equivalent to Javascript's JSON.parse(), but for a Luan value.  In addition to the usual JSON values, Luan.parse allows long strings and allows specifying numeric types of <i>double</i>, <i>float</i>, <i>integer</i>, and <i>long</i>.  For example:</p>
+
+<code block>
+local t = Luan.parse[=[
+{
+	nothing = nil
+	t = true
+	f = false
+	s = "string"
+	ls = [[long string]]
+	n = 3
+	d = double(3)
+	f = float(3)
+	i = integer(3)
+	l = long(3)
+	list = { 1, 2, 3 }
+	table = {
+		one = 1
+		two = 2
+		three = 3
+	}
+	["ugly-key"] = "something"
+}
+]=]
+</code>
+<%
+						end
+					}
 					["Luan.range"] = {
 						title = "Luan.range (start, stop [, step])"
 						content = function()
@@ -2291,8 +2348,19 @@
 						content = function()
 %>
 <p>
-Receives a value of any type and converts it to a string that is a Luan expression.  <code>options</code> is a table.  If <code>options.strict==true</code> then invalid types throw an error.  Otherwise invalid types are represented but the resulting expression is invalid.  If <code>options.number_types==true</code> then numbers will be wrapped in functions for their type.
-</p>
+This Luan's equivalent to Javascript's JSON.stringify(), but for a Luan value.  
+<code>v</code> is a value of any type which is converted to a string that is a Luan expression.  <code>options</code> may be a table or a function.  If <code>options</code> is a table, it may contain the following flags whose <code>true</code> value means:
+</p>
+
+<ul>
+<li><b>strict</b> - invalid types throw an error</li>
+<li><b>number_types</b> - numbers will be wrapped in functions for their type</li>
+<li><b>compressed</b> - eliminates white space</li>
+<li><b>inline</b> - on one line</li>
+<li><b>no_name_keys</b> - forces all keys to be of the form <code>["key"]</code></li>
+</ul>
+
+<p>If <code>options</code> is a function then this function should take an argument <code>stack</code> and return an <code>options</code> table.  The <code>stack</code> will be a list of keys indicating where stringify is currently processing.  This allows different options to be applied at different places in a data structure.</p>
 <%
 						end
 					}