Mercurial Hosting > luan
comparison website/src/manual.html @ 1327:b29eefad2111
website - improve docs
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 08 Feb 2019 00:45:31 -0700 |
parents | 29d6d7d79c41 |
children | 60599adc27b8 |
comparison
equal
deleted
inserted
replaced
1326:29d6d7d79c41 | 1327:b29eefad2111 |
---|---|
11 <div small> | 11 <div small> |
12 <a href=".">Luan</a> | 12 <a href=".">Luan</a> |
13 / <a href="docs.html">Documentation</a> | 13 / <a href="docs.html">Documentation</a> |
14 </div> | 14 </div> |
15 | 15 |
16 <h1>Luan Reference Manual</h1> | 16 <h1><a href="manual.html">Luan Reference Manual</a></h1> |
17 | 17 |
18 <p small> | 18 <p small> |
19 Original copyright © 2015 Lua.org, PUC-Rio. | 19 Original copyright © 2015 Lua.org, PUC-Rio. |
20 Freely available under the terms of the | 20 Freely available under the terms of the |
21 <a href="http://www.lua.org/license.html">Lua license</a>. | 21 <a href="http://www.lua.org/license.html">Lua license</a>. |
92 </div> | 92 </div> |
93 | 93 |
94 <hr/> | 94 <hr/> |
95 | 95 |
96 | 96 |
97 <h2 heading><a name="intro">Introduction</a></h2> | 97 <h2 heading><a name="intro" href="#intro">Introduction</a></h2> |
98 | 98 |
99 <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> | 99 <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> |
100 | 100 |
101 <p>Luan is implemented in Java and is tightly coupled with Java. So it makes a great scripting language for Java programmers.</p> | 101 <p>Luan is implemented in Java and is tightly coupled with Java. So it makes a great scripting language for Java programmers.</p> |
102 | 102 |
103 <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> | 103 <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> |
104 | 104 |
105 | 105 |
106 <h2 heading><a name="basic">Basic Concepts</a></h2> | 106 <h2 heading><a name="basic" href="#basic">Basic Concepts</a></h2> |
107 | 107 |
108 <p>This section describes the basic concepts of the language.</p> | 108 <p>This section describes the basic concepts of the language.</p> |
109 | 109 |
110 <h3 heading><a name="types">Values and Types</a></h3> | 110 <h3 heading><a name="types" href="#types">Values and Types</a></h3> |
111 | 111 |
112 <p> | 112 <p> |
113 Luan is a <em>dynamically typed language</em>. | 113 Luan is a <em>dynamically typed language</em>. |
114 This means that | 114 This means that |
115 variables do not have types; only values do. | 115 variables do not have types; only values do. |
224 | 224 |
225 | 225 |
226 | 226 |
227 | 227 |
228 | 228 |
229 <h3 heading><a name="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 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>. |
233 | 233 |
234 <p> | 234 <p> |
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> |
238 can be syntactically translated to <code>_ENV.var</code> if <code>_ENV</code> is defined. | 238 can be syntactically translated to <code>_ENV.var</code> if <code>_ENV</code> is defined. |
239 | 239 |
240 | 240 |
241 <h3 heading><a name="error">Error Handling</a></h3> | 241 <h3 heading><a name="error" href="#error">Error Handling</a></h3> |
242 | 242 |
243 <p> | 243 <p> |
244 Luan code can explicitly generate an error by calling the | 244 Luan code can explicitly generate an error by calling the |
245 <a href="#Luan.error"><code>error</code></a> function. | 245 <a href="#Luan.error"><code>error</code></a> function. |
246 If you need to catch errors in Luan, | 246 If you need to catch errors in Luan, |
254 is propagated with information about the error. | 254 is propagated with information about the error. |
255 See <a href="#Luan.new_error"><code>Luan.new_error</code></a>. | 255 See <a href="#Luan.new_error"><code>Luan.new_error</code></a>. |
256 | 256 |
257 | 257 |
258 | 258 |
259 <h3 heading><a name="meta">Metatables and Metamethods</a></h3> | 259 <h3 heading><a name="meta" href="#meta">Metatables and Metamethods</a></h3> |
260 | 260 |
261 <p> | 261 <p> |
262 Every table in Luan can have a <em>metatable</em>. | 262 Every table in Luan can have a <em>metatable</em>. |
263 This <em>metatable</em> is an ordinary Luan table | 263 This <em>metatable</em> is an ordinary Luan table |
264 that defines the behavior of the original value | 264 that defines the behavior of the original value |
473 </ul> | 473 </ul> |
474 | 474 |
475 | 475 |
476 | 476 |
477 | 477 |
478 <h3 heading><a name="gc">Garbage Collection</a></h3> | 478 <h3 heading><a name="gc" href="#gc">Garbage Collection</a></h3> |
479 | 479 |
480 <p> | 480 <p> |
481 Luan uses Java's garbage collection. | 481 Luan uses Java's garbage collection. |
482 | 482 |
483 | 483 |
484 | 484 |
485 | 485 |
486 | 486 |
487 <h2 heading><a name="lang">The Language</a></h2> | 487 <h2 heading><a name="lang" href="#lang">The Language</a></h2> |
488 | 488 |
489 <p> | 489 <p> |
490 This section describes the lexis, the syntax, and the semantics of Luan. | 490 This section describes the lexis, the syntax, and the semantics of Luan. |
491 In other words, | 491 In other words, |
492 this section describes | 492 this section describes |
506 The complete syntax of Luan can be found in <a href="#9">§9</a> | 506 The complete syntax of Luan can be found in <a href="#9">§9</a> |
507 at the end of this manual. | 507 at the end of this manual. |
508 | 508 |
509 | 509 |
510 | 510 |
511 <h3 heading><a name="lex">Lexical Conventions</a></h3> | 511 <h3 heading><a name="lex" href="#lex">Lexical Conventions</a></h3> |
512 | 512 |
513 <p> | 513 <p> |
514 Luan ignores spaces and comments | 514 Luan ignores spaces and comments |
515 between lexical elements (tokens), | 515 between lexical elements (tokens), |
516 except as delimiters between names and keywords. | 516 except as delimiters between names and keywords. |
684 | 684 |
685 | 685 |
686 | 686 |
687 | 687 |
688 | 688 |
689 <h3 heading><a name="vars">Variables</a></h3> | 689 <h3 heading><a name="vars" href="#vars">Variables</a></h3> |
690 | 690 |
691 <p> | 691 <p> |
692 Variables are places that store values. | 692 Variables are places that store values. |
693 There are three kinds of variables in Luan: | 693 There are three kinds of variables in Luan: |
694 global variables, local variables, and table fields. | 694 global variables, local variables, and table fields. |
747 | 747 |
748 | 748 |
749 | 749 |
750 | 750 |
751 | 751 |
752 <h3 heading><a name="stmts">Statements</a></h3> | 752 <h3 heading><a name="stmts" href="#stmts">Statements</a></h3> |
753 | 753 |
754 <p> | 754 <p> |
755 Luan supports an almost conventional set of statements, | 755 Luan supports an almost conventional set of statements, |
756 similar to those in Pascal or C. | 756 similar to those in Pascal or C. |
757 This set includes | 757 This set includes |
758 assignments, control structures, function calls, | 758 assignments, control structures, function calls, |
759 and variable declarations. | 759 and variable declarations. |
760 | 760 |
761 | 761 |
762 | 762 |
763 <h4 heading><a name="blocks">Blocks</a></h4> | 763 <h4 heading><a name="blocks" href="#blocks">Blocks</a></h4> |
764 | 764 |
765 <p> | 765 <p> |
766 A block is a list of statements, | 766 A block is a list of statements, |
767 which are executed sequentially: | 767 which are executed sequentially: |
768 | 768 |
797 | 797 |
798 | 798 |
799 | 799 |
800 | 800 |
801 | 801 |
802 <h4 heading><a name="chunks">Chunks</a></h4> | 802 <h4 heading><a name="chunks" href="#chunks">Chunks</a></h4> |
803 | 803 |
804 <p> | 804 <p> |
805 The unit of compilation of Luan is called a <em>chunk</em>. | 805 The unit of compilation of Luan is called a <em>chunk</em>. |
806 Syntactically, | 806 Syntactically, |
807 a chunk is simply a block: | 807 a chunk is simply a block: |
827 | 827 |
828 | 828 |
829 | 829 |
830 | 830 |
831 | 831 |
832 <h4 heading><a name="assignment">Assignment</a></h4> | 832 <h4 heading><a name="assignment" href="#assignment">Assignment</a></h4> |
833 | 833 |
834 <p> | 834 <p> |
835 Luan allows multiple assignments. | 835 Luan allows multiple assignments. |
836 Therefore, the syntax for assignment | 836 Therefore, the syntax for assignment |
837 defines a list of variables on the left side | 837 defines a list of variables on the left side |
911 <code>_ENV.x = val</code> (see <a href="#env">Environments</a>). | 911 <code>_ENV.x = val</code> (see <a href="#env">Environments</a>). |
912 Global names are only available when <code>_ENV</code> is defined. | 912 Global names are only available when <code>_ENV</code> is defined. |
913 | 913 |
914 | 914 |
915 | 915 |
916 <h4 heading><a name="control">Control Structures</a></h4> | 916 <h4 heading><a name="control" href="#control">Control Structures</a></h4> |
917 | 917 |
918 <p> | 918 <p> |
919 The control structures | 919 The control structures |
920 <b>if</b>, <b>while</b>, and <b>repeat</b> have the usual meaning and | 920 <b>if</b>, <b>while</b>, and <b>repeat</b> have the usual meaning and |
921 familiar syntax: | 921 familiar syntax: |
974 </pre> | 974 </pre> |
975 | 975 |
976 | 976 |
977 | 977 |
978 | 978 |
979 <h4 heading><a name="for">For Statement</a></h4> | 979 <h4 heading><a name="for" href="#for">For Statement</a></h4> |
980 | 980 |
981 <p> | 981 <p> |
982 The <b>for</b> statement works over functions, | 982 The <b>for</b> statement works over functions, |
983 called <em>iterators</em>. | 983 called <em>iterators</em>. |
984 On each iteration, the iterator function is called to produce a new value, | 984 On each iteration, the iterator function is called to produce a new value, |
1041 </ul> | 1041 </ul> |
1042 | 1042 |
1043 | 1043 |
1044 | 1044 |
1045 | 1045 |
1046 <h4 heading><a name="fn_stmt">Function Calls as Statements</a></h4> | 1046 <h4 heading><a name="fn_stmt" href="#fn_stmt">Function Calls as Statements</a></h4> |
1047 | 1047 |
1048 <p> | 1048 <p> |
1049 To allow possible side-effects, | 1049 To allow possible side-effects, |
1050 function calls can be executed as statements: | 1050 function calls can be executed as statements: |
1051 | 1051 |
1057 In this case, all returned values are thrown away. | 1057 In this case, all returned values are thrown away. |
1058 Function calls are explained in <a href="#fn_calls">Function Calls</a>. | 1058 Function calls are explained in <a href="#fn_calls">Function Calls</a>. |
1059 | 1059 |
1060 | 1060 |
1061 | 1061 |
1062 <h4 heading><a name="local_stmt">Local Declarations</a></h4> | 1062 <h4 heading><a name="local_stmt" href="#local_stmt">Local Declarations</a></h4> |
1063 | 1063 |
1064 <p> | 1064 <p> |
1065 Local variables can be declared anywhere inside a block. | 1065 Local variables can be declared anywhere inside a block. |
1066 The declaration can include an initial assignment: | 1066 The declaration can include an initial assignment: |
1067 | 1067 |
1082 | 1082 |
1083 <p> | 1083 <p> |
1084 The visibility rules for local variables are explained in <a href="#visibility">Visibility Rules</a>. | 1084 The visibility rules for local variables are explained in <a href="#visibility">Visibility Rules</a>. |
1085 | 1085 |
1086 | 1086 |
1087 <h4 heading><a name="template_stmt">Template Statements</a></h4> | 1087 <h4 heading><a name="template_stmt" href="#template_stmt">Template Statements</a></h4> |
1088 | 1088 |
1089 <p>Template statements are based on <a href="#template_expr">template exressions</a> and provide the full equivalent of <a href="http://en.wikipedia.org/wiki/JavaServer_Pages">JSP</a> but in a general way. Template statements write the equivalent template exression to standard output. For example:</p> | 1089 <p>Template statements are based on <a href="#template_expr">template exressions</a> and provide the full equivalent of <a href="http://en.wikipedia.org/wiki/JavaServer_Pages">JSP</a> but in a general way. Template statements write the equivalent template exression to standard output. For example:</p> |
1090 | 1090 |
1091 <pre> | 1091 <pre> |
1092 local name = "Bob" | 1092 local name = "Bob" |
1106 <% ) | 1106 <% ) |
1107 </pre> | 1107 </pre> |
1108 | 1108 |
1109 | 1109 |
1110 | 1110 |
1111 <h3 heading><a name="expressions">Expressions</a></h3> | 1111 <h3 heading><a name="expressions" href="#expressions">Expressions</a></h3> |
1112 | 1112 |
1113 <p> | 1113 <p> |
1114 The basic expressions in Luan are the following: | 1114 The basic expressions in Luan are the following: |
1115 | 1115 |
1116 <pre> | 1116 <pre> |
1192 (The value of <code>(f(x,y,z))</code> is the first value returned by <code>f</code> | 1192 (The value of <code>(f(x,y,z))</code> is the first value returned by <code>f</code> |
1193 or <b>nil</b> if <code>f</code> does not return any values.) | 1193 or <b>nil</b> if <code>f</code> does not return any values.) |
1194 | 1194 |
1195 | 1195 |
1196 | 1196 |
1197 <h4 heading><a name="arithmetic">Arithmetic Operators</a></h4> | 1197 <h4 heading><a name="arithmetic" href="#arithmetic">Arithmetic Operators</a></h4> |
1198 | 1198 |
1199 <p> | 1199 <p> |
1200 Luan supports the following arithmetic operators: | 1200 Luan supports the following arithmetic operators: |
1201 | 1201 |
1202 <ul> | 1202 <ul> |
1217 that rounds the quotient towards minus infinite (floor division). | 1217 that rounds the quotient towards minus infinite (floor division). |
1218 (The Java modulo operator is not used.) | 1218 (The Java modulo operator is not used.) |
1219 | 1219 |
1220 | 1220 |
1221 | 1221 |
1222 <h4 heading><a name="conversions">Coercions and Conversions</a></h4> | 1222 <h4 heading><a name="conversions" href="#conversions">Coercions and Conversions</a></h4> |
1223 | 1223 |
1224 <p> | 1224 <p> |
1225 Luan generally avoids automatic conversions. | 1225 Luan generally avoids automatic conversions. |
1226 String concatenation automatically converts all of its arguments to strings. | 1226 String concatenation automatically converts all of its arguments to strings. |
1227 | 1227 |
1229 Luan provides library functions for explicit type conversions. | 1229 Luan provides library functions for explicit type conversions. |
1230 | 1230 |
1231 | 1231 |
1232 | 1232 |
1233 | 1233 |
1234 <h4 heading><a name="relational">Relational Operators</a></h4> | 1234 <h4 heading><a name="relational" href="#relational">Relational Operators</a></h4> |
1235 | 1235 |
1236 <p> | 1236 <p> |
1237 Luan supports the following relational operators: | 1237 Luan supports the following relational operators: |
1238 | 1238 |
1239 <ul> | 1239 <ul> |
1295 | 1295 |
1296 | 1296 |
1297 | 1297 |
1298 | 1298 |
1299 | 1299 |
1300 <h4 heading><a name="logical_ops">Logical Operators</a></h4> | 1300 <h4 heading><a name="logical_ops" href="#logical_ops">Logical Operators</a></h4> |
1301 | 1301 |
1302 <p> | 1302 <p> |
1303 The logical operators in Luan are | 1303 The logical operators in Luan are |
1304 <b>and</b>, <b>or</b>, and <b>not</b>. | 1304 <b>and</b>, <b>or</b>, and <b>not</b>. |
1305 The <b>and</b> and <b>or</b> operators consider both <b>false</b> and <b>nil</b> as false | 1305 The <b>and</b> and <b>or</b> operators consider both <b>false</b> and <b>nil</b> as false |
1335 (In this manual, | 1335 (In this manual, |
1336 <code>--></code> indicates the result of the preceding expression.) | 1336 <code>--></code> indicates the result of the preceding expression.) |
1337 | 1337 |
1338 | 1338 |
1339 | 1339 |
1340 <h4 heading><a name="concatenation">Concatenation</a></h4> | 1340 <h4 heading><a name="concatenation" href="#concatenation">Concatenation</a></h4> |
1341 | 1341 |
1342 <p> | 1342 <p> |
1343 The string concatenation operator in Luan is | 1343 The string concatenation operator in Luan is |
1344 denoted by two dots ('<code>..</code>'). | 1344 denoted by two dots ('<code>..</code>'). |
1345 All operands are converted to strings. | 1345 All operands are converted to strings. |
1346 | 1346 |
1347 | 1347 |
1348 | 1348 |
1349 <h4 heading><a name="length">The Length Operator</a></h4> | 1349 <h4 heading><a name="length" href="#length">The Length Operator</a></h4> |
1350 | 1350 |
1351 <p> | 1351 <p> |
1352 The length operator is denoted by the unary prefix operator <code>#</code>. | 1352 The length operator is denoted by the unary prefix operator <code>#</code>. |
1353 The length of a string is its number of characters. | 1353 The length of a string is its number of characters. |
1354 The length of a binary is its number of bytes. | 1354 The length of a binary is its number of bytes. |
1378 | 1378 |
1379 | 1379 |
1380 | 1380 |
1381 | 1381 |
1382 | 1382 |
1383 <h4 heading><a name="precedence">Precedence</a></h4> | 1383 <h4 heading><a name="precedence" href="#precedence">Precedence</a></h4> |
1384 | 1384 |
1385 <p> | 1385 <p> |
1386 Operator precedence in Luan follows the table below, | 1386 Operator precedence in Luan follows the table below, |
1387 from lower to higher priority: | 1387 from lower to higher priority: |
1388 | 1388 |
1406 | 1406 |
1407 | 1407 |
1408 | 1408 |
1409 | 1409 |
1410 | 1410 |
1411 <h4 heading><a name="constructors">Table Constructors</a></h4> | 1411 <h4 heading><a name="constructors" href="#constructors">Table Constructors</a></h4> |
1412 | 1412 |
1413 <p> | 1413 <p> |
1414 Table constructors are expressions that create tables. | 1414 Table constructors are expressions that create tables. |
1415 Every time a constructor is evaluated, a new table is created. | 1415 Every time a constructor is evaluated, a new table is created. |
1416 A constructor can be used to create an empty table | 1416 A constructor can be used to create an empty table |
1474 | 1474 |
1475 | 1475 |
1476 | 1476 |
1477 | 1477 |
1478 | 1478 |
1479 <h4 heading><a name="fn_calls">Function Calls</a></h4> | 1479 <h4 heading><a name="fn_calls" href="#fn_calls">Function Calls</a></h4> |
1480 | 1480 |
1481 <p> | 1481 <p> |
1482 A function call in Luan has the following syntax: | 1482 A function call in Luan has the following syntax: |
1483 | 1483 |
1484 <pre> | 1484 <pre> |
1513 that is, the argument list is a single literal string. | 1513 that is, the argument list is a single literal string. |
1514 | 1514 |
1515 | 1515 |
1516 | 1516 |
1517 | 1517 |
1518 <h4 heading><a name="fn_def">Function Definitions</a></h4> | 1518 <h4 heading><a name="fn_def" href="#fn_def">Function Definitions</a></h4> |
1519 | 1519 |
1520 <p> | 1520 <p> |
1521 The syntax for function definition is | 1521 The syntax for function definition is |
1522 | 1522 |
1523 <pre> | 1523 <pre> |
1662 If control reaches the end of a function | 1662 If control reaches the end of a function |
1663 without encountering a <b>return</b> statement, | 1663 without encountering a <b>return</b> statement, |
1664 then the function returns with no results. | 1664 then the function returns with no results. |
1665 | 1665 |
1666 | 1666 |
1667 <h4 heading><a name="template_expr">Template Expressions</a></h4> | 1667 <h4 heading><a name="template_expr" href="#template_expr">Template Expressions</a></h4> |
1668 | 1668 |
1669 <p>Luan template expression are based on <a href="http://en.wikipedia.org/wiki/JavaServer_Pages">JSP</a>. Template expressions return multiple values. Here is an example:</p> | 1669 <p>Luan template expression are based on <a href="http://en.wikipedia.org/wiki/JavaServer_Pages">JSP</a>. Template expressions return multiple values. Here is an example:</p> |
1670 | 1670 |
1671 <pre> | 1671 <pre> |
1672 local name = "Bob" | 1672 local name = "Bob" |
1682 | 1682 |
1683 <p>The strings in template expressions may be multiple lines.</p> | 1683 <p>The strings in template expressions may be multiple lines.</p> |
1684 | 1684 |
1685 | 1685 |
1686 | 1686 |
1687 <h3 heading><a name="visibility">Visibility Rules</a></h3> | 1687 <h3 heading><a name="visibility" href="#visibility">Visibility Rules</a></h3> |
1688 | 1688 |
1689 <p> | 1689 <p> |
1690 Luan is a lexically scoped language. | 1690 Luan is a lexically scoped language. |
1691 The scope of a local variable begins at the first statement after | 1691 The scope of a local variable begins at the first statement after |
1692 its declaration and lasts until the last non-void statement | 1692 its declaration and lasts until the last non-void statement |
1745 | 1745 |
1746 | 1746 |
1747 | 1747 |
1748 | 1748 |
1749 | 1749 |
1750 <h2 heading><a name="libs">Standard Libraries</a></h2> | 1750 <h2 heading><a name="libs" href="#libs">Standard Libraries</a></h2> |
1751 | 1751 |
1752 <p> | 1752 <p> |
1753 The standard Luan libraries provide useful functions | 1753 The standard Luan libraries provide useful functions |
1754 that are implemented both in Java and in Luan itself. | 1754 that are implemented both in Java and in Luan itself. |
1755 How each function is implemented shouldn't matter to the user. | 1755 How each function is implemented shouldn't matter to the user. |
1756 Some of these functions provide essential services to the language | 1756 Some of these functions provide essential services to the language |
1757 (e.g., <a href="#Luan.type"><code>type</code></a> and <a href="#Luan.get_metatable"><code>get_metatable</code></a>); | 1757 (e.g., <a href="#Luan.type"><code>type</code></a> and <a href="#Luan.get_metatable"><code>get_metatable</code></a>); |
1758 others provide access to "outside" services (e.g., I/O). | 1758 others provide access to "outside" services (e.g., I/O). |
1759 | 1759 |
1760 | 1760 |
1761 <h3 heading><a name="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 These are provided by default as local variables for any Luan code as described in <a href="#env">Environments</a>. |
1765 | 1765 |
1766 | 1766 |
1767 <h4 heading><a name="require"><code>java ()</code></a></h4> | 1767 <h4 heading><a name="java" href="#java"><code>java ()</code></a></h4> |
1768 | 1768 |
1769 <p> | 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. | 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 | 1771 |
1772 | 1772 |
1773 <h4 heading><a name="require"><code>require (mod_uri)</code></a></h4> | 1773 <h4 heading><a name="require" href="#require"><code>require (mod_uri)</code></a></h4> |
1774 | 1774 |
1775 <p> | 1775 <p> |
1776 Example use: | 1776 Example use: |
1777 | 1777 |
1778 <pre> | 1778 <pre> |
1787 return <a href="#Package.load">Package.load</a>(mod_name) or <a href="#Luan.error">Luan.error</a>("module '"..mod_name.."' not found") | 1787 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 | 1788 end |
1789 </pre> | 1789 </pre> |
1790 | 1790 |
1791 | 1791 |
1792 <h3 heading><a name="luan_lib">Basic Functions</a></h3> | 1792 <h3 heading><a name="luan_lib" href="#luan_lib">Basic Functions</a></h3> |
1793 | 1793 |
1794 <p> | 1794 <p> |
1795 Include this library by: | 1795 Include this library by: |
1796 | 1796 |
1797 <pre> | 1797 <pre> |
2182 | 2182 |
2183 | 2183 |
2184 | 2184 |
2185 | 2185 |
2186 | 2186 |
2187 <h3 heading><a name="package_lib">Modules</a></h3> | 2187 <h3 heading><a name="package_lib" href="#package_lib">Modules</a></h3> |
2188 | 2188 |
2189 <p> | 2189 <p> |
2190 Include this library by: | 2190 Include this library by: |
2191 | 2191 |
2192 <pre> | 2192 <pre> |
2239 | 2239 |
2240 | 2240 |
2241 | 2241 |
2242 | 2242 |
2243 | 2243 |
2244 <h3 heading><a name="string_lib">String Manipulation</a></h3> | 2244 <h3 heading><a name="string_lib" href="#string_lib">String Manipulation</a></h3> |
2245 | 2245 |
2246 <p> | 2246 <p> |
2247 Include this library by: | 2247 Include this library by: |
2248 | 2248 |
2249 <pre> | 2249 <pre> |
2591 | 2591 |
2592 | 2592 |
2593 | 2593 |
2594 | 2594 |
2595 | 2595 |
2596 <h3 heading><a name="binary_lib">Binary Manipulation</a></h3> | 2596 <h3 heading><a name="binary_lib" href="#binary_lib">Binary Manipulation</a></h3> |
2597 | 2597 |
2598 <p> | 2598 <p> |
2599 Include this library by: | 2599 Include this library by: |
2600 | 2600 |
2601 <pre> | 2601 <pre> |
2628 If <code>charset</code> is not nil then converts the binary <code>b</code> to a string using the Java <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#String(byte[],%20java.lang.String)">String constructor</a>, else makes each byte a char. | 2628 If <code>charset</code> is not nil then converts the binary <code>b</code> to a string using the Java <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#String(byte[],%20java.lang.String)">String constructor</a>, else makes each byte a char. |
2629 | 2629 |
2630 | 2630 |
2631 | 2631 |
2632 | 2632 |
2633 <h3 heading><a name="table_lib">Table Manipulation</a></h3> | 2633 <h3 heading><a name="table_lib" href="#table_lib">Table Manipulation</a></h3> |
2634 | 2634 |
2635 <p> | 2635 <p> |
2636 Include this library by: | 2636 Include this library by: |
2637 | 2637 |
2638 <pre> | 2638 <pre> |
2748 By default, <code>i</code> is 1 and <code>j</code> is <code>list.n or #list</code>. | 2748 By default, <code>i</code> is 1 and <code>j</code> is <code>list.n or #list</code>. |
2749 | 2749 |
2750 | 2750 |
2751 | 2751 |
2752 | 2752 |
2753 <h3 heading><a name="number_lib">Number Manipulation</a></h3> | 2753 <h3 heading><a name="number_lib" href="#number_lib">Number Manipulation</a></h3> |
2754 | 2754 |
2755 <p> | 2755 <p> |
2756 Include this library by: | 2756 Include this library by: |
2757 | 2757 |
2758 <pre> | 2758 <pre> |
2789 Returns a string for the numeric type of <code>x</code>. Possible return values include "<code>integer</code>", "<code>long</code>", "<code>double</code>", and "<code>float</code>". | 2789 Returns a string for the numeric type of <code>x</code>. Possible return values include "<code>integer</code>", "<code>long</code>", "<code>double</code>", and "<code>float</code>". |
2790 | 2790 |
2791 | 2791 |
2792 | 2792 |
2793 | 2793 |
2794 <h3 heading><a name="math_lib">Mathematical Functions</a></h3> | 2794 <h3 heading><a name="math_lib" href="#math_lib">Mathematical Functions</a></h3> |
2795 | 2795 |
2796 <p> | 2796 <p> |
2797 Include this library by: | 2797 Include this library by: |
2798 | 2798 |
2799 <pre> | 2799 <pre> |