diff website/src/manual.html.luan @ 512:d96944467ffc

update documentation for luan changes
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 22 May 2015 16:08:23 -0600
parents 7bc63886d4f2
children 0dfc01d8d42d
line wrap: on
line diff
--- a/website/src/manual.html.luan	Fri May 22 10:47:56 2015 -0600
+++ b/website/src/manual.html.luan	Fri May 22 16:08:23 2015 -0600
@@ -232,38 +232,13 @@
 <h3 <%=heading_options%> ><a name="env">Environments</a></h3>
 
 <p>
+The environment of a chunk starts with only two local variables: <tt><a href="#require">require</a></tt> and <tt><a href="#java">java</a></tt>.  These are functions are used to load and access libraries and other modules.  All other variables must be added to the environment using <a href="http://localhost:8080/manual.html#local_stmt">local declarations</a>.
+
+<p>
 As will be discussed in <a href="#vars">Variables</a> and <a href=#assignment">Assignment</a>,
 any reference to a free name
 (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 <tt>_ENV</tt> (see <a href="#chunks">Chunks</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,
-<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 <tt>_ENV</tt> that is
-visible at that point in the program,
-following the usual visibility rules of Luan (see <a href="#visibility">Visibility Rules</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.
-
-
+can be syntactically translated to <tt>_ENV.var</tt> if <tt>_ENV</tt> is defined.
 
 
 <h3 <%=heading_options%> ><a name="error">Error Handling</a></h3>
@@ -723,7 +698,6 @@
 There are three kinds of variables in Luan:
 global variables, local variables, and table fields.
 
-
 <p>
 A single name can denote a global variable or a local variable
 (or a function's formal parameter,
@@ -736,10 +710,7 @@
 <p>
 Name denotes identifiers, as defined in <a href="#lex">Lexical Conventions</a>.
 
-
-<p>
-Any variable name is assumed to be global unless explicitly declared
-as a local (see <a href="#local_stmt">Local Declarations</a>).
+<p>
 Local variables are <i>lexically scoped</i>:
 local variables can be freely accessed by functions
 defined inside their scope (see <a href="#visibility">Visibility Rules</a>).
@@ -748,7 +719,6 @@
 <p>
 Before the first assignment to a variable, its value is <b>nil</b>.
 
-
 <p>
 Square brackets are used to index a table:
 
@@ -775,7 +745,7 @@
 </pre></tt></p>
 
 <p>
-An access to a global variable <tt>x</tt>
+Global variables are not available by default.  To enable global variable, you must define <tt>_ENV</tt> as a local variable whose value is a table.  If <tt>_ENV</tt> is not defined, then an unrecognized variable name will produce a compile error.  If <tt>_ENV</tt> is defined then an access to an unrecognized variable name will be consider a global variable.  So then an acces to global variable <tt>x</tt>
 is equivalent to <tt>_ENV.x</tt>.
 Due to the way that chunks are compiled,
 <tt>_ENV</tt> is never a global name (see <a href="#env">Environments</a>).
@@ -943,7 +913,7 @@
 An assignment to a global name <tt>x = val</tt>
 is equivalent to the assignment
 <tt>_ENV.x = val</tt> (see <a href="#env">Environments</a>).
-
+Global names are only available when <tt>_ENV</tt> is defined.
 
 
 
@@ -1824,12 +1794,6 @@
 These are provided by default as local variables for any Luan code as described in <a href="#env">Environments</a>.
 
 
-<h4 <%=heading_options%> ><a name="_ENV"><tt>_ENV</tt></a></h4>
-
-<p>
-This is a table that holds the global variables of a module as described in <a href="#env">Environments</a>.
-
-
 <h4 <%=heading_options%> ><a name="require"><tt>java ()</tt></a></h4>
 
 <p>