changeset 353:38c19ecc384d

start documentation
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 13 Apr 2015 15:49:10 -0600
parents 90c8406bf735
children 705e4d6c3dbb
files website/src/diff.html website/src/index.html
diffstat 2 files changed, 159 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/website/src/diff.html	Mon Apr 13 15:49:10 2015 -0600
@@ -0,0 +1,156 @@
+<!DOCTYPE html>
+<html lang="en">
+	<head>
+		<meta charset="utf-8">
+		<meta name="viewport" content="width=device-width, initial-scale=1">
+
+		<title>Luan Documentation</title>
+		
+		<link href="http://www.simplyhtml.org/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
+		<link rel="stylesheet" href="http://www.simplyhtml.org/assets/font-awesome/css/font-awesome.min.css">
+		<script src="http://www.simplyhtml.org/assets/jquery/jquery.min.js"></script>
+
+		<link href="http://www.simplyhtml.org/assets/simplyhtml/simplyhtml.css" rel="stylesheet"/>
+		<script src="http://www.simplyhtml.org/assets/simplyhtml/simplyhtml.js"></script>
+	</head>
+	<body>
+		<div container>
+			<h1>How Luan differs from Lua</h1>
+
+			<p>This document explains how <a href="/">Luan</a> 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>
+
+			<h2>Contents</h2>
+
+			<p><a href="#intro">Introduction</a></p>
+
+			<p>
+				<a href="#basic">Basic Concepts</a>
+				<ul>
+					<li><a href="#types">Values and Types</a></li>
+					<li><a href="#env">Environments</a></li>
+					<li><a href="#error">Error Handling</a></li>
+					<li><a href="#meta">Metatables and Metamethods</a></li>
+					<li><a href="#gc">Garbage Collection</a></li>
+					<li><a href="#coroutines">Coroutines</a></li>
+				</ul>
+			</p>
+
+			<p>
+				<a href="#lang">The Language</a>
+				<ul>
+					<li><a href="#lex">Lexical Conventions</a></li>
+					<li>
+						<a href="#stmt">Statements</a>
+						<ul>
+							<li><a href="#control">Control Structures</a></li>
+							<li><a href="#for">For Statement</a></li>
+							<li><a href="#logical">Logical Statements</a></li>
+						</ul>
+					</li>
+				</ul>
+			</p>
+
+			<h2><a name="intro">Introduction</a></h2>
+
+			<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>
+
+			<p>Luan is implemented in Java and is tightly integrated with Java.  This makes it an excellent scripting language for Java.</p>
+
+			<h2><a name="basic">Basic Concepts</a></h2>
+
+			<h4 margin-top="1em"><a name="types">Values and Types</a></h4>
+
+			<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>
+
+			<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>
+
+			<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>
+
+			<p>Luan <i>userdata</i> is nothing more than a Java object that doesn't fall into one of the other recognized types.</p>
+
+			<p>The Luan <i>binary</i> type is the Java <i>byte[ ]</i> type which is an array of bytes.</p>
+
+			<p>The Luan <i>table</i> type is just like its Lua equivalent, but implemented in Java.</p>
+
+			<h4 margin-top="1em"><a name="env">Environments</a></h4>
+
+			<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>
+
+			<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>
+
+			<h4 margin-top="1em"><a name="error">Error Handling</a></h4>
+
+			<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>
+
+			<h4 margin-top="1em"><a name="meta">Metatables and Metamethods</a></h4>
+
+			<p>to document later...</p>
+
+			<h4 margin-top="1em"><a name="gc">Garbage Collection</a></h4>
+
+			<p>Luan uses Java garbage collection.  Luan has no special garbage collection methods.</p>
+
+			<p>Luan does not yet have weak tables but this will be added.</p>
+
+			<h4 margin-top="1em"><a name="coroutines">Coroutines</a></h4>
+
+			<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>
+
+			<h2><a name="lang">The Language</a></h2>
+
+			<h4 margin-top="1em"><a name="lex">Lexical Conventions</a></h4>
+
+			<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>
+
+			<p>Luan has exactly the same set of keywords as Lua and has the same other lexical conventions.</p>
+
+			<h4 margin-top="1em"><a name="stmt">Statements</a></h4>
+
+			<p>Most statements in Luan are the same as Lua.  Only those statements that differ will be listed here.</p>
+
+			<h5 margin-top="1em"><a name="control">Control Structures</a></h5>
+
+			<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>
+
+			<p>Luan does not have a <b>goto</b> statement.</p>
+
+			<h5 margin-top="1em"><a name="for">For Statement</a></h5>
+
+			<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>
+
+			<tt><pre>
+	for i in range(from,to,step) do <i>block</i> end
+			</pre></tt>
+
+			<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>
+
+			<tt><pre>
+	for var_1, ···, var_n in exp do block end
+			</pre></tt>
+
+			<p>is equivalent to the code:</p>
+
+			<tt><pre>
+	do
+		local f = exp
+		while true do
+			local var_1, ···, var_n = f()
+			if var_1 == nil then break end
+			block
+		end
+	end
+			</pre></tt>
+
+			<h5 margin-top="1em"><a name="logical">Logical Statements</a></h5>
+
+			<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>
+
+			<tt><pre>
+	x==5 or error "x should be 5"
+			</pre></tt>
+
+		</div>
+		
+		<script src="http://www.simplyhtml.org/assets/bootstrap/js/bootstrap.min.js"></script>
+	</body>
+</html>
--- a/website/src/index.html	Mon Apr 13 09:32:12 2015 -0600
+++ b/website/src/index.html	Mon Apr 13 15:49:10 2015 -0600
@@ -20,12 +20,14 @@
 				<p margin-bottom="2em">under construction...</p>
 				<p>Luan is a <a href="http://www.lua.org">Lua</a>-like language implemented in <a href="https://www.oracle.com/java/">Java</a>.</p>
 				<p>
+					<a href="diff.html">Documentation</a><br>
 					<a href="https://www.dropbox.com/sh/i7imf67wzj7z3h2/AABrpM0L1apqHysb_ot5t2dla?dl=0
 	">Download</a><br>
 					<a href="https://bitbucket.org/frschmidt/luan">Source</a><br>
-					<a href="http://luan.7479.n7.nabble.com">Forum</a><br>
+					<a href="http://luan.7479.n7.nabble.com/">Forum</a><br>
 				</p>
 			</big>
+			<p margin-top="2em"><small>This website was made with <a href="http://www.simplyhtml.org/">SimplyHTML</a>.</small></p>
 		</div>
 		
 		<script src="http://www.simplyhtml.org/assets/bootstrap/js/bootstrap.min.js"></script>