diff website/src/manual.html @ 373:571057b1666b

work on manual
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 17 Apr 2015 15:14:44 -0600
parents f08cefa4594c
children 6c6c3537035e
line wrap: on
line diff
--- a/website/src/manual.html	Fri Apr 17 07:58:20 2015 -0600
+++ b/website/src/manual.html	Fri Apr 17 15:14:44 2015 -0600
@@ -35,8 +35,19 @@
 
 <div margin-bottom="1em"><a href="#intro">Introduction</a></div>
 
+<div margin-bottom="1em">
+	<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>
+	</ul>
+</div>
+
 <hr/>
 
+
 <h2 margin-top="1em"><a name="intro">Introduction</a></h2>
 
 <p>Luan is a high level programming language based on <a href="http://www.lua.org">Lua</a>.  A great strength of Lua is its simplicity and Luan takes this even further, being even simpler than Lua.  The goal is to provide a simple programming language for the casual programmer with as few concepts as possible so that one can quickly learn the language and then easily understand any code written in Luan.</p>
@@ -46,17 +57,14 @@
 <p>Unlike Lua which is meant to be embedded, Luan is meant to be a full scripting language.  This done not by adding feature to Luan, but rather by providing a complete set of libraries.</p>
 
 
-<h1>2 &ndash; <a name="2">Basic Concepts</a></h1>
-
-<p>
-This section describes the basic concepts of the language.
-
-
-
-<h2>2.1 &ndash; <a name="2.1">Values and Types</a></h2>
-
-<p>
-Lua is a <em>dynamically typed language</em>.
+<h2 margin-top="1em"><a name="basic">Basic Concepts</a></h2>
+
+<p>This section describes the basic concepts of the language.</p>
+
+<h3 margin-top="1em"><a name="types">Values and Types</a></h3>
+
+<p>
+Luan is a <i>dynamically typed language</i>.
 This means that
 variables do not have types; only values do.
 There are no type definitions in the language.
@@ -64,91 +72,52 @@
 
 
 <p>
-All values in Lua are <em>first-class values</em>.
+All values in Luan are <i>first-class values</i>.
 This means that all values can be stored in variables,
 passed as arguments to other functions, and returned as results.
 
 
 <p>
-There are eight basic types in Lua:
-<em>nil</em>, <em>boolean</em>, <em>number</em>,
-<em>string</em>, <em>function</em>, <em>userdata</em>,
-<em>thread</em>, and <em>table</em>.
-<em>Nil</em> is the type of the value <b>nil</b>,
+There are eight basic types in Luan:
+<i>nil</i>, <i>boolean</i>, <i>number</i>,
+<i>string</i>, <i>binary</i>, <i>function</i>, <i>userdata</i>,
+and <i>table</i>.
+<i>Nil</i> is the type of the value <b>nil</b>,
 whose main property is to be different from any other value;
 it usually represents the absence of a useful value.
-<em>Boolean</em> is the type of the values <b>false</b> and <b>true</b>.
-Both <b>nil</b> and <b>false</b> make a condition false;
-any other value makes it true.
-<em>Number</em> represents both
+<i>Nil</i> is implemented as the Java value <i>null</i>.
+<i>Boolean</i> is the type of the values <b>false</b> and <b>true</b>.
+<i>Boolean</i> is implemented as the Java class <i>Boolean</i>.
+<i>Number</i> represents both
 integer numbers and real (floating-point) numbers.
-<em>String</em> represents immutable sequences of bytes.
-
-Lua is 8-bit clean:
-strings can contain any 8-bit value,
-including embedded zeros ('<code>\0</code>').
-Lua is also encoding-agnostic;
-it makes no assumptions about the contents of a string.
-
-
-<p>
-The type <em>number</em> uses two internal representations,
-one called <em>integer</em> and the other called <em>float</em>.
-Lua has explicit rules about when each representation is used,
-but it also converts between them automatically as needed (see <a href="#3.4.3">&sect;3.4.3</a>).
-Therefore,
-the programmer may choose to mostly ignore the difference
-between integers and floats
-or to assume complete control over the representation of each number.
-Standard Lua uses 64-bit integers and double-precision (64-bit) floats,
-but you can also compile Lua so that it
-uses 32-bit integers and/or single-precision (32-bit) floats.
-The option with 32 bits for both integers and floats 
-is particularly attractive
-for small machines and embedded systems.
-(See macro <code>LUA_32BITS</code> in file <code>luaconf.h</code>.)
-
-
-<p>
-Lua can call (and manipulate) functions written in Lua and
-functions written in C (see <a href="#3.4.10">&sect;3.4.10</a>).
-Both are represented by the type <em>function</em>.
-
-
-<p>
-The type <em>userdata</em> is provided to allow arbitrary C&nbsp;data to
-be stored in Lua variables.
-A userdata value represents a block of raw memory.
-There are two kinds of userdata:
-<em>full userdata</em>,
-which is an object with a block of memory managed by Lua,
-and <em>light userdata</em>,
-which is simply a C&nbsp;pointer value.
-Userdata has no predefined operations in Lua,
+<i>Number</i> is implemented as the Java class <i>Number</i>.  Any Java subclass of <i>Number</i> is allowed and this is invisible to the Luan user.  Operations on numbers follow the same rules of
+the underlying Java implementation.
+
+<i>String</i> is implemented as the Java class <i>String</i>.
+<i>Binary</i> is implemented as the Java type <i>byte[]</i>.
+
+
+<p>
+Luan can call (and manipulate) functions written in Luan and
+functions written in Java (see <a href="#3.4.10">&sect;3.4.10</a>).
+Both are represented by the type <i>function</i>.
+
+
+<p>
+The type <i>userdata</i> is provided to allow arbitrary Java objects to
+be stored in Luan variables.
+A userdata value is a Java object that isn't one of the standard Luan types.
+Userdata has no predefined operations in Luan,
 except assignment and identity test.
-By using <em>metatables</em>,
-the programmer can define operations for full userdata values
-(see <a href="#2.4">&sect;2.4</a>).
-Userdata values cannot be created or modified in Lua,
-only through the C&nbsp;API.
-This guarantees the integrity of data owned by the host program.
-
-
-<p>
-The type <em>thread</em> represents independent threads of execution
-and it is used to implement coroutines (see <a href="#2.6">&sect;2.6</a>).
-Lua threads are not related to operating-system threads.
-Lua supports coroutines on all systems,
-even those that do not support threads natively.
-
-
-<p>
-The type <em>table</em> implements associative arrays,
+Userdata is useful then Java access is enabled in Luan
+
+
+
+<p>
+The type <i>table</i> implements associative arrays,
 that is, arrays that can be indexed not only with numbers,
-but with any Lua value except <b>nil</b> and NaN.
-(<em>Not a Number</em> is a special numeric value used to represent
-undefined or unrepresentable results, such as <code>0/0</code>.)
-Tables can be <em>heterogeneous</em>;
+but with any Luan value except <b>nil</b>.
+Tables can be <i>heterogeneous</i>;
 that is, they can contain values of all types (except <b>nil</b>).
 Any key with value <b>nil</b> is not considered part of the table.
 Conversely, any key that is not part of a table has
@@ -156,20 +125,20 @@
 
 
 <p>
-Tables are the sole data-structuring mechanism in Lua;
+Tables are the sole data-structuring mechanism in Luan;
 they can be used to represent ordinary arrays, sequences,
 symbol tables, sets, records, graphs, trees, etc.
-To represent records, Lua uses the field name as an index.
+To represent records, Luan uses the field name as an index.
 The language supports this representation by
-providing <code>a.name</code> as syntactic sugar for <code>a["name"]</code>.
-There are several convenient ways to create tables in Lua
+providing <tt>a.name</tt> as syntactic sugar for <tt>a["name"]</tt>.
+There are several convenient ways to create tables in Luan
 (see <a href="#3.4.9">&sect;3.4.9</a>).
 
 
 <p>
-We use the term <em>sequence</em> to denote a table where
-the set of all positive numeric keys is equal to {1..<em>n</em>}
-for some non-negative integer <em>n</em>,
+We use the term <i>sequence</i> to denote a table where
+the set of all positive numeric keys is equal to {1..<i>n</i>}
+for some non-negative integer <i>n</i>,
 which is called the length of the sequence (see <a href="#3.4.7">&sect;3.4.7</a>).
 
 
@@ -179,243 +148,167 @@
 In particular,
 because functions are first-class values,
 table fields can contain functions.
-Thus tables can also carry <em>methods</em> (see <a href="#3.4.11">&sect;3.4.11</a>).
+Thus tables can also carry <i>methods</i> (see <a href="#3.4.11">&sect;3.4.11</a>).
 
 
 <p>
 The indexing of tables follows
 the definition of raw equality in the language.
-The expressions <code>a[i]</code> and <code>a[j]</code>
+The expressions <tt>a[i]</tt> and <tt>a[j]</tt>
 denote the same table element
-if and only if <code>i</code> and <code>j</code> are raw equal
+if and only if <tt>i</tt> and <tt>j</tt> are raw equal
 (that is, equal without metamethods).
 In particular, floats with integral values
 are equal to their respective integers
-(e.g., <code>1.0 == 1</code>).
-To avoid ambiguities,
-any float with integral value used as a key
-is converted to its respective integer.
-For instance, if you write <code>a[2.0] = true</code>,
-the actual key inserted into the table will be the
-integer <code>2</code>.
-(On the other hand,
-2 and "<code>2</code>" are different Lua values and therefore
-denote different table entries.)
-
-
-<p>
-Tables, functions, threads, and (full) userdata values are <em>objects</em>:
-variables do not actually <em>contain</em> these values,
-only <em>references</em> to them.
+(e.g., <tt>1.0 == 1</tt>).
+
+
+<p>
+Luan values are <i>objects</i>:
+variables do not actually <i>contain</i> values,
+only <i>references</i> to them.
 Assignment, parameter passing, and function returns
-always manipulate references to such values;
+always manipulate references to values;
 these operations do not imply any kind of copy.
 
 
 <p>
-The library function <a href="#pdf-type"><code>type</code></a> returns a string describing the type
+The library function <a href="#pdf-type"><tt>Luan.type</tt></a> returns a string describing the type
 of a given value (see <a href="#6.1">&sect;6.1</a>).
 
 
 
 
 
-<h2>2.2 &ndash; <a name="2.2">Environments and the Global Environment</a></h2>
+<h3 margin-top="1em"><a name="env">Environments</a></h3>
 
 <p>
 As will be discussed in <a href="#3.2">&sect;3.2</a> and <a href="#3.3.3">&sect;3.3.3</a>,
 any reference to a free name
-(that is, a name not bound to any declaration) <code>var</code>
-is syntactically translated to <code>_ENV.var</code>.
+(that is, a name not bound to any declaration) <tt>var</tt>
+is syntactically translated to <tt>_ENV.var</tt>.
 Moreover, every chunk is compiled in the scope of
-an external local variable named <code>_ENV</code> (see <a href="#3.3.2">&sect;3.3.2</a>),
-so <code>_ENV</code> itself is never a free name in a chunk.
-
-
-<p>
-Despite the existence of this external <code>_ENV</code> variable and
+an external local variable named <tt>_ENV</tt> (see <a href="#3.3.2">&sect;3.3.2</a>),
+so <tt>_ENV</tt> itself is never a free name in a chunk.
+
+
+<p>
+Despite the existence of this external <tt>_ENV</tt> variable and
 the translation of free names,
-<code>_ENV</code> is a completely regular name.
+<tt>_ENV</tt> is a completely regular name.
 In particular,
 you can define new variables and parameters with that name.
-Each reference to a free name uses the <code>_ENV</code> that is
+Each reference to a free name uses the <tt>_ENV</tt> that is
 visible at that point in the program,
-following the usual visibility rules of Lua (see <a href="#3.5">&sect;3.5</a>).
-
-
-<p>
-Any table used as the value of <code>_ENV</code> is called an <em>environment</em>.
-
-
-<p>
-Lua keeps a distinguished environment called the <em>global environment</em>.
-This value is kept at a special index in the C registry (see <a href="#4.5">&sect;4.5</a>).
-In Lua, the global variable <a href="#pdf-_G"><code>_G</code></a> is initialized with this same value.
-(<a href="#pdf-_G"><code>_G</code></a> is never used internally.)
-
-
-<p>
-When Lua loads a chunk,
-the default value for its <code>_ENV</code> upvalue
-is the global environment (see <a href="#pdf-load"><code>load</code></a>).
-Therefore, by default,
-free names in Lua code refer to entries in the global environment
-(and, therefore, they are also called <em>global variables</em>).
-Moreover, all standard libraries are loaded in the global environment
-and some functions there operate on that environment.
-You can use <a href="#pdf-load"><code>load</code></a> (or <a href="#pdf-loadfile"><code>loadfile</code></a>)
-to load a chunk with a different environment.
-(In C, you have to load the chunk and then change the value
-of its first upvalue.)
-
-
-
-
-
-<h2>2.3 &ndash; <a name="2.3">Error Handling</a></h2>
-
-<p>
-Because Lua is an embedded extension language,
-all Lua actions start from C&nbsp;code in the host program
-calling a function from the Lua library.
-(When you use Lua standalone,
-the <code>lua</code> application is the host program.)
-Whenever an error occurs during
-the compilation or execution of a Lua chunk,
-control returns to the host,
-which can take appropriate measures
-(such as printing an error message).
-
-
-<p>
-Lua code can explicitly generate an error by calling the
-<a href="#pdf-error"><code>error</code></a> function.
-If you need to catch errors in Lua,
-you can use <a href="#pdf-pcall"><code>pcall</code></a> or <a href="#pdf-xpcall"><code>xpcall</code></a>
-to call a given function in <em>protected mode</em>.
+following the usual visibility rules of Luan (see <a href="#3.5">&sect;3.5</a>).
+
+
+<p>
+Any table used as the value of <tt>_ENV</tt> is called an <i>environment</i>.
+
+
+<p>
+When Luan loads a chunk,
+the default value for its <tt>_ENV</tt> is an empty table.
+
+<p>
+Luan also provides all chunks with two other local values: <tt>require</tt> and <tt>java</tt>.  These are functions used to load and access libraries and other modules.
+
+
+
+
+<h3 margin-top="1em"><a name="error">Error Handling</a></h3>
+
+<p>
+Luan code can explicitly generate an error by calling the
+<a href="#pdf-error"><tt>error</tt></a> function.
+If you need to catch errors in Luan,
+you can use <a href="#pdf-pcall"><tt>pcall</tt></a> or <a href="#pdf-xpcall"><tt>try</tt></a>
+to call a given function in <i>protected mode</i>.
 
 
 <p>
 Whenever there is an error,
-an <em>error object</em> (also called an <em>error message</em>)
+an <i>error object</i> (also called an <i>error message</i>)
 is propagated with information about the error.
-Lua itself only generates errors whose error object is a string,
+Luan itself only generates errors whose error object is a string,
 but programs may generate errors with
 any value as the error object.
-It is up to the Lua program or its host to handle such error objects.
-
-
-<p>
-When you use <a href="#pdf-xpcall"><code>xpcall</code></a> or <a href="#lua_pcall"><code>lua_pcall</code></a>,
-you may give a <em>message handler</em>
-to be called in case of errors.
-This function is called with the original error message
-and returns a new error message.
-It is called before the error unwinds the stack,
-so that it can gather more information about the error,
-for instance by inspecting the stack and creating a stack traceback.
-This message handler is still protected by the protected call;
-so, an error inside the message handler
-will call the message handler again.
-If this loop goes on for too long,
-Lua breaks it and returns an appropriate message.
-
-
-
-
-
-<h2>2.4 &ndash; <a name="2.4">Metatables and Metamethods</a></h2>
-
-<p>
-Every value in Lua can have a <em>metatable</em>.
-This <em>metatable</em> is an ordinary Lua table
+It is up to the Luan program or its host to handle such error objects.
+
+
+
+
+
+<h3 margin-top="1em"><a name="meta">Metatables and Metamethods</a></h3>
+
+<p>
+Every table in Luan can have a <i>metatable</i>.
+This <i>metatable</i> is an ordinary Luan table
 that defines the behavior of the original value
 under certain special operations.
 You can change several aspects of the behavior
 of operations over a value by setting specific fields in its metatable.
-For instance, when a non-numeric value is the operand of an addition,
-Lua checks for a function in the field "<code>__add</code>" of the value's metatable.
+For instance, when a table is the operand of an addition,
+Luan checks for a function in the field "<tt>__add</tt>" of the table's metatable.
 If it finds one,
-Lua calls this function to perform the addition.
-
-
-<p>
-The keys in a metatable are derived from the <em>event</em> names;
-the corresponding values are called <em>metamethods</em>.
-In the previous example, the event is <code>"add"</code>
+Luan calls this function to perform the addition.
+
+
+<p>
+The keys in a metatable are derived from the <i>event</i> names;
+the corresponding values are called <ii>metamethods</i>.
+In the previous example, the event is <tt>"add"</tt>
 and the metamethod is the function that performs the addition.
 
 
 <p>
-You can query the metatable of any value
-using the <a href="#pdf-getmetatable"><code>getmetatable</code></a> function.
+You can query the metatable of any table
+using the <a href="#pdf-getmetatable"><tt>get_metatable</tt></a> function.
 
 
 <p>
 You can replace the metatable of tables
-using the <a href="#pdf-setmetatable"><code>setmetatable</code></a> function.
-You cannot change the metatable of other types from Lua
-(except by using the debug library (<a href="#6.10">&sect;6.10</a>));
-you must use the C&nbsp;API for that.
-
-
-<p>
-Tables and full userdata have individual metatables
-(although multiple tables and userdata can share their metatables).
-Values of all other types share one single metatable per type;
-that is, there is one single metatable for all numbers,
-one for all strings, etc.
-By default, a value has no metatable,
-but the string library sets a metatable for the string type (see <a href="#6.4">&sect;6.4</a>).
-
-
-<p>
-A metatable controls how an object behaves in
+using the <a href="#pdf-setmetatable"><tt>set_metatable</tt></a> function.
+
+
+<p>
+A metatable controls how a table behaves in
 arithmetic operations, bitwise operations,
 order comparisons, concatenation, length operation, calls, and indexing.
-A metatable also can define a function to be called
-when a userdata or a table is garbage collected (<a href="#2.5">&sect;2.5</a>).
 
 
 <p>
 A detailed list of events controlled by metatables is given next.
 Each operation is identified by its corresponding event name.
 The key for each event is a string with its name prefixed by
-two underscores, '<code>__</code>';
+two underscores, '<tt>__</tt>';
 for instance, the key for operation "add" is the
-string "<code>__add</code>".
+string "<tt>__add</tt>".
 Note that queries for metamethods are always raw;
 the access to a metamethod does not invoke other metamethods.
-You can emulate how Lua queries a metamethod for an object <code>obj</code>
+You can emulate how Luan queries a metamethod for an object <tt>obj</tt>
 with the following code:
 
-<pre>
-     rawget(getmetatable(obj) or {}, "__" .. event_name)
-</pre>
-
-<p>
-For the unary operators (negation, length, and bitwise not),
-the metamethod is computed and called with a dummy second operand,
-equal to the first one.
-This extra operand is only to simplify Lua's internals
-(by making these operators behave like a binary operation)
-and may be removed in future versions.
-(For most uses this extra operand is irrelevant.)
-
-
+<tt><pre>
+     raw_get(get_metatable(obj) or {}, "__" .. event_name)
+
+</pre></tt>
+
+<p>
+Here are the events:
 
 <ul>
 
 <li><b>"add": </b>
-the <code>+</code> operation.
-
-If any operand for an addition is not a number
-(nor a string coercible to a number),
-Lua will try to call a metamethod.
-First, Lua will check the first operand (even if it is valid).
-If that operand does not define a metamethod for the "<code>__add</code>" event,
-then Lua will check the second operand.
-If Lua can find a metamethod,
+the <tt>+</tt> operation.
+
+If any operand for an addition is a table,
+Luan will try to call a metamethod.
+First, Luan will check the first operand (even if it is valid).
+If that operand does not define a metamethod for the "<tt>__add</tt>" event,
+then Luan will check the second operand.
+If Luan can find a metamethod,
 it calls the metamethod with the two operands as arguments,
 and the result of the call
 (adjusted to one value)
@@ -425,199 +318,146 @@
 </li>
 
 <li><b>"sub": </b>
-the <code>-</code> operation.
+the <tt>-</tt> operation.
 
 Behavior similar to the "add" operation.
 </li>
 
 <li><b>"mul": </b>
-the <code>*</code> operation.
+the <tt>*</tt> operation.
 
 Behavior similar to the "add" operation.
 </li>
 
 <li><b>"div": </b>
-the <code>/</code> operation.
+the <tt>/</tt> operation.
 
 Behavior similar to the "add" operation.
 </li>
 
 <li><b>"mod": </b>
-the <code>%</code> operation.
+the <tt>%</tt> operation.
 
 Behavior similar to the "add" operation.
 </li>
 
 <li><b>"pow": </b>
-the <code>^</code> (exponentiation) operation.
+the <tt>^</tt> (exponentiation) operation.
 
 Behavior similar to the "add" operation.
 </li>
 
 <li><b>"unm": </b>
-the <code>-</code> (unary minus) operation.
-
-Behavior similar to the "add" operation.
-</li>
-
-<li><b>"idiv": </b>
-the <code>//</code> (floor division) operation.
+the <tt>-</tt> (unary minus) operation.
 
 Behavior similar to the "add" operation.
 </li>
 
-<li><b>"band": </b>
-the <code>&amp;</code> (bitwise and) operation.
-
-Behavior similar to the "add" operation,
-except that Lua will try a metamethod
-if any operator is neither an integer
-nor a value coercible to an integer (see <a href="#3.4.3">&sect;3.4.3</a>).
-</li>
-
-<li><b>"bor": </b>
-the <code>|</code> (bitwise or) operation.
-
-Behavior similar to the "band" operation.
-</li>
-
-<li><b>"bxor": </b>
-the <code>~</code> (bitwise exclusive or) operation.
-
-Behavior similar to the "band" operation.
-</li>
-
-<li><b>"bnot": </b>
-the <code>~</code> (bitwise unary not) operation.
-
-Behavior similar to the "band" operation.
-</li>
-
-<li><b>"shl": </b>
-the <code>&lt;&lt;</code> (bitwise left shift) operation.
-
-Behavior similar to the "band" operation.
-</li>
-
-<li><b>"shr": </b>
-the <code>&gt;&gt;</code> (bitwise right shift) operation.
-
-Behavior similar to the "band" operation.
-</li>
-
 <li><b>"concat": </b>
-the <code>..</code> (concatenation) operation.
-
-Behavior similar to the "add" operation,
-except that Lua will try a metamethod
-if any operator is neither a string nor a number
-(which is always coercible to a string).
+the <tt>..</tt> (concatenation) operation.
+
+Behavior similar to the "add" operation.
 </li>
 
 <li><b>"len": </b>
-the <code>#</code> (length) operation.
-
-If the object is not a string,
-Lua will try its metamethod.
+the <tt>#</tt> (length) operation.
+
 If there is a metamethod,
-Lua calls it with the object as argument,
+Luan calls it with the object as argument,
 and the result of the call
 (always adjusted to one value)
 is the result of the operation.
 If there is no metamethod but the object is a table,
-then Lua uses the table length operation (see <a href="#3.4.7">&sect;3.4.7</a>).
-Otherwise, Lua raises an error.
+then Luan uses the table length operation (see <a href="#3.4.7">&sect;3.4.7</a>).
+Otherwise, Luan raises an error.
 </li>
 
 <li><b>"eq": </b>
-the <code>==</code> (equal) operation.
+the <tt>==</tt> (equal) operation.
 
 Behavior similar to the "add" operation,
-except that Lua will try a metamethod only when the values
-being compared are either both tables or both full userdata
+except that Luan will try a metamethod only when the values
+being compared are both tables
 and they are not primitively equal.
 The result of the call is always converted to a boolean.
 </li>
 
 <li><b>"lt": </b>
-the <code>&lt;</code> (less than) operation.
-
-Behavior similar to the "add" operation,
-except that Lua will try a metamethod only when the values
-being compared are neither both numbers nor both strings.
+the <tt>&lt;</tt> (less than) operation.
+
+Behavior similar to the "add" operation.
 The result of the call is always converted to a boolean.
 </li>
 
 <li><b>"le": </b>
-the <code>&lt;=</code> (less equal) operation.
+the <tt>&lt;=</tt> (less equal) operation.
 
 Unlike other operations,
 The less-equal operation can use two different events.
-First, Lua looks for the "<code>__le</code>" metamethod in both operands,
+First, Luan looks for the "<tt>__le</tt>" metamethod in both operands,
 like in the "lt" operation.
 If it cannot find such a metamethod,
-then it will try the "<code>__lt</code>" event,
-assuming that <code>a &lt;= b</code> is equivalent to <code>not (b &lt; a)</code>.
+then it will try the "<tt>__lt</tt>" event,
+assuming that <tt>a &lt;= b</tt> is equivalent to <tt>not (b &lt; a)</tt>.
 As with the other comparison operators,
 the result is always a boolean.
 </li>
 
 <li><b>"index": </b>
-The indexing access <code>table[key]</code>.
-
-This event happens when <code>table</code> is not a table or
-when <code>key</code> is not present in <code>table</code>.
-The metamethod is looked up in <code>table</code>.
+The indexing access <tt>table[key]</tt>.
+
+This event happens
+when <tt>key</tt> is not present in <tt>table</tt>.
+The metamethod is looked up in <tt>table</tt>.
 
 
 <p>
 Despite the name,
 the metamethod for this event can be either a function or a table.
 If it is a function,
-it is called with <code>table</code> and <code>key</code> as arguments.
+it is called with <tt>table</tt> and <tt>key</tt> as arguments.
 If it is a table,
-the final result is the result of indexing this table with <code>key</code>.
+the final result is the result of indexing this table with <tt>key</tt>.
 (This indexing is regular, not raw,
 and therefore can trigger another metamethod.)
 </li>
 
 <li><b>"newindex": </b>
-The indexing assignment <code>table[key] = value</code>.
+The indexing assignment <tt>table[key] = value</tt>.
 
 Like the index event,
-this event happens when <code>table</code> is not a table or
-when <code>key</code> is not present in <code>table</code>.
-The metamethod is looked up in <code>table</code>.
+this event happens when
+when <tt>key</tt> is not present in <tt>table</tt>.
+The metamethod is looked up in <tt>table</tt>.
 
 
 <p>
 Like with indexing,
 the metamethod for this event can be either a function or a table.
 If it is a function,
-it is called with <code>table</code>, <code>key</code>, and <code>value</code> as arguments.
+it is called with <tt>table</tt>, <tt>key</tt>, and <tt>value</tt> as arguments.
 If it is a table,
-Lua does an indexing assignment to this table with the same key and value.
+Luan does an indexing assignment to this table with the same key and value.
 (This assignment is regular, not raw,
 and therefore can trigger another metamethod.)
 
 
 <p>
 Whenever there is a "newindex" metamethod,
-Lua does not perform the primitive assignment.
+Luan does not perform the primitive assignment.
 (If necessary,
-the metamethod itself can call <a href="#pdf-rawset"><code>rawset</code></a>
+the metamethod itself can call <a href="#pdf-rawset"><tt>raw_set</tt></a>
 to do the assignment.)
 </li>
 
 <li><b>"call": </b>
-The call operation <code>func(args)</code>.
-
-This event happens when Lua tries to call a non-function value
-(that is, <code>func</code> is not a function).
-The metamethod is looked up in <code>func</code>.
+The call operation <tt>func(args)</tt>.
+
+This event happens when Luan tries to call a table.
+The metamethod is looked up in <tt>func</tt>.
 If present,
-the metamethod is called with <code>func</code> as its first argument,
-followed by the arguments of the original call (<code>args</code>).
+the metamethod is called with <tt>func</tt> as its first argument,
+followed by the arguments of the original call (<tt>args</tt>).
 </li>
 
 </ul>