comparison website/src/manual.html @ 1353:8d95711f6615

replace java() with require "java"
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 20 Mar 2019 17:03:29 -0600
parents 60599adc27b8
children 372906d1d08b
comparison
equal deleted inserted replaced
1352:1604d7f36f3a 1353:8d95711f6615
227 227
228 228
229 <h3 heading><a name="env" href="#env">Environments</a></h3> 229 <h3 heading><a name="env" href="#env">Environments</a></h3>
230 230
231 <p> 231 <p>
232 The environment of a chunk starts with only two local variables: <code><a href="#require">require</a></code> and <code><a href="#java">java</a></code>. 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>. 232 The environment of a chunk starts with only one local variable: <code><a href="#require">require</a></code>. This function is 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>.
233 233
234 <p> 234 <p>
235 As will be discussed in <a href="#vars">Variables</a> and <a href=#assignment">Assignment</a>, 235 As will be discussed in <a href="#vars">Variables</a> and <a href=#assignment">Assignment</a>,
236 any reference to a free name 236 any reference to a free name
237 (that is, a name not bound to any declaration) <code>var</code> 237 (that is, a name not bound to any declaration) <code>var</code>
1759 1759
1760 1760
1761 <h3 heading><a name="default_lib" href="#default_lib">Default Environment</a></h3> 1761 <h3 heading><a name="default_lib" href="#default_lib">Default Environment</a></h3>
1762 1762
1763 <p> 1763 <p>
1764 These are provided by default as local variables for any Luan code as described in <a href="#env">Environments</a>. 1764 This is provided by default as a local variable for any Luan code as described in <a href="#env">Environments</a>.
1765
1766
1767 <h4 heading><a name="java" href="#java"><code>java ()</code></a></h4>
1768
1769 <p>
1770 This function enables Java in the current chunk if that chunk has permission to use Java. If the chunk doesn't have permission to use Java, then an error is thrown.
1771 1765
1772 1766
1773 <h4 heading><a name="require" href="#require"><code>require (mod_uri)</code></a></h4> 1767 <h4 heading><a name="require" href="#require"><code>require (mod_uri)</code></a></h4>
1774 1768
1775 <p> 1769 <p>
1785 <pre> 1779 <pre>
1786 local function require(mod_name) 1780 local function require(mod_name)
1787 return <a href="#Package.load">Package.load</a>(mod_name) or <a href="#Luan.error">Luan.error</a>("module '"..mod_name.."' not found") 1781 return <a href="#Package.load">Package.load</a>(mod_name) or <a href="#Luan.error">Luan.error</a>("module '"..mod_name.."' not found")
1788 end 1782 end
1789 </pre> 1783 </pre>
1784
1785 <p>
1786 A special case is:
1787
1788 <pre>
1789 require "java"
1790 </pre>
1791
1792 <p>
1793 This enables Java in the current chunk if that chunk has permission to use Java. If the chunk doesn't have permission to use Java, then an error is thrown.
1790 1794
1791 1795
1792 <h3 heading><a name="luan_lib" href="#luan_lib">Basic Functions</a></h3> 1796 <h3 heading><a name="luan_lib" href="#luan_lib">Basic Functions</a></h3>
1793 1797
1794 <p> 1798 <p>