Mercurial Hosting > luan
changeset 468:9b51e2413cab
documentation
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 08 May 2015 17:29:28 -0600 |
parents | f86bf532f87c |
children | 85467f95ab13 |
files | website/src/diff.html.luan website/src/manual.html.luan |
diffstat | 2 files changed, 27 insertions(+), 64 deletions(-) [+] |
line wrap: on
line diff
--- a/website/src/diff.html.luan Fri May 08 12:10:53 2015 -0600 +++ b/website/src/diff.html.luan Fri May 08 17:29:28 2015 -0600 @@ -139,7 +139,7 @@ for i in range(from,to,step) do <i>block</i> end </pre></tt></p> -<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> +<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> <p><tt><pre> for var_1, ···, var_n in exp do block end
--- a/website/src/manual.html.luan Fri May 08 12:10:53 2015 -0600 +++ b/website/src/manual.html.luan Fri May 08 17:29:28 2015 -0600 @@ -83,6 +83,13 @@ </ul> </div> +<div margin-bottom="1em"> + <a href="#libs">Standard Libraries</a> + <ul> + <li><a href="#default_lib">Default Environment</a></li> + </ul> +</div> + <hr/> @@ -1801,70 +1808,26 @@ -<h1>6 – <a name="6">Standard Libraries</a></h1> - -<p> -The standard Lua libraries provide useful functions -that are implemented directly through the C API. +<h2 margin-top="1em"><a name="libs">Standard Libraries</a></h2> + +<p> +The standard Luan libraries provide useful functions +that are implemented both in Java and in Luan itself. +How each function is implemented shouldn't matter to the user. Some of these functions provide essential services to the language -(e.g., <a href="#pdf-type"><code>type</code></a> and <a href="#pdf-getmetatable"><code>getmetatable</code></a>); -others provide access to "outside" services (e.g., I/O); -and others could be implemented in Lua itself, -but are quite useful or have critical performance requirements that -deserve an implementation in C (e.g., <a href="#pdf-table.sort"><code>table.sort</code></a>). - - -<p> -All libraries are implemented through the official C API -and are provided as separate C modules. -Currently, Lua has the following standard libraries: - -<ul> - -<li>basic library (<a href="#6.1">§6.1</a>);</li> - -<li>coroutine library (<a href="#6.2">§6.2</a>);</li> - -<li>package library (<a href="#6.3">§6.3</a>);</li> - -<li>string manipulation (<a href="#6.4">§6.4</a>);</li> - -<li>basic UTF-8 support (<a href="#6.5">§6.5</a>);</li> - -<li>table manipulation (<a href="#6.6">§6.6</a>);</li> - -<li>mathematical functions (<a href="#6.7">§6.7</a>) (sin, log, etc.);</li> - -<li>input and output (<a href="#6.8">§6.8</a>);</li> - -<li>operating system facilities (<a href="#6.9">§6.9</a>);</li> - -<li>debug facilities (<a href="#6.10">§6.10</a>).</li> - -</ul><p> -Except for the basic and the package libraries, -each library provides all its functions as fields of a global table -or as methods of its objects. - - -<p> -To have access to these libraries, -the C host program should call the <a href="#luaL_openlibs"><code>luaL_openlibs</code></a> function, -which opens all standard libraries. -Alternatively, -the host program can open them individually by using -<a href="#luaL_requiref"><code>luaL_requiref</code></a> to call -<a name="pdf-luaopen_base"><code>luaopen_base</code></a> (for the basic library), -<a name="pdf-luaopen_package"><code>luaopen_package</code></a> (for the package library), -<a name="pdf-luaopen_coroutine"><code>luaopen_coroutine</code></a> (for the coroutine library), -<a name="pdf-luaopen_string"><code>luaopen_string</code></a> (for the string library), -<a name="pdf-luaopen_utf8"><code>luaopen_utf8</code></a> (for the UTF8 library), -<a name="pdf-luaopen_table"><code>luaopen_table</code></a> (for the table library), -<a name="pdf-luaopen_math"><code>luaopen_math</code></a> (for the mathematical library), -<a name="pdf-luaopen_io"><code>luaopen_io</code></a> (for the I/O library), -<a name="pdf-luaopen_os"><code>luaopen_os</code></a> (for the operating system library), -and <a name="pdf-luaopen_debug"><code>luaopen_debug</code></a> (for the debug library). -These functions are declared in <a name="pdf-lualib.h"><code>lualib.h</code></a>. +(e.g., <a href="#pdf-type"><tt>type</tt></a> and <a href="#pdf-getmetatable"><tt>get_metatable</tt></a>); +others provide access to "outside" services (e.g., I/O). + + +<h3 margin-top="1em"><a name="default_lib">Default Environment</a></h3> + +<p> +These are provided by default as local variables for any Luan code as described in <a href="#env">Environments</a>. + +<h4 margin-top="1em"><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>.