comparison website/src/manual.html.luan @ 693:ca169567ce07

module URIs must now include ".luan"
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 19 Apr 2016 15:54:11 -0600
parents 1e4b0bc0202d
children 5042e487d717
comparison
equal deleted inserted replaced
692:7bd97d642f37 693:ca169567ce07
1 local Luan = require "luan:Luan" 1 local Luan = require "luan:Luan.luan"
2 local Io = require "luan:Io" 2 local Io = require "luan:Io.luan"
3 local Html = require "luan:Html" 3 local Html = require "luan:Html.luan"
4 local Http = require "luan:http/Http" 4 local Http = require "luan:http/Http.luan"
5 local Shared = require "site:/Shared" 5 local Shared = require "site:/Shared.luan"
6 6
7 7
8 return function() 8 return function()
9 Io.stdout = Http.response.text_writer() 9 Io.stdout = Http.response.text_writer()
10 %> 10 %>
1093 1093
1094 <p>is equivalent to the code:</p> 1094 <p>is equivalent to the code:</p>
1095 1095
1096 <pre><%=Html.encode[[ 1096 <pre><%=Html.encode[[
1097 local name = "Bob" 1097 local name = "Bob"
1098 require("luan:Io").stdout.write( %> 1098 require("luan:Io.luan").stdout.write( %>
1099 Hello <%= name %>! 1099 Hello <%= name %>!
1100 Bye <%= name %>. 1100 Bye <%= name %>.
1101 <% ) 1101 <% )
1102 ]]%></pre> 1102 ]]%></pre>
1103 1103
1768 1768
1769 <p> 1769 <p>
1770 Example use: 1770 Example use:
1771 1771
1772 <pre> 1772 <pre>
1773 local Table = require "luan:Table" 1773 local Table = require "luan:Table.luan"
1774 </pre> 1774 </pre>
1775 1775
1776 <p> 1776 <p>
1777 Could be defined as: 1777 Could be defined as:
1778 1778
1787 1787
1788 <p> 1788 <p>
1789 Include this library by: 1789 Include this library by:
1790 1790
1791 <pre> 1791 <pre>
1792 local Luan = require "luan:Luan" 1792 local Luan = require "luan:Luan.luan"
1793 </pre> 1793 </pre>
1794 1794
1795 <p> 1795 <p>
1796 The basic library provides basic functions to Luan that don't depend on other libaries. 1796 The basic library provides basic functions to Luan that don't depend on other libaries.
1797 1797
1953 1953
1954 <p> 1954 <p>
1955 If the <code>allow_expression</code> parameter is <code>true</code> then the entire text can be nothing more than an expression in which case the chunk returns the value of this expression. 1955 If the <code>allow_expression</code> parameter is <code>true</code> then the entire text can be nothing more than an expression in which case the chunk returns the value of this expression.
1956 1956
1957 1957
1958 <h4 heading><a name="Luan.load_file" href="#Luan.load_file"><code>Luan.load_file (file_uri [, add_extension])</code></a></h4> 1958 <h4 heading><a name="Luan.load_file" href="#Luan.load_file"><code>Luan.load_file ([file_uri])</code></a></h4>
1959 1959
1960 <p> 1960 <p>
1961 Similar to <a href="#Luan.load"><code>load</code></a>, 1961 Similar to <a href="#Luan.load"><code>load</code></a>,
1962 but gets the chunk from file <code>file_uri</code> 1962 but gets the chunk from file <code>file_uri</code>
1963 or from the standard input, 1963 or from the standard input,
1965 1965
1966 <p> 1966 <p>
1967 Could be defined as: 1967 Could be defined as:
1968 1968
1969 <pre> 1969 <pre>
1970 function Luan.load_file(file_uri,add_extension) 1970 function Luan.load_file(file_uri)
1971 file_uri = file_uri or "stdin:" 1971 file_uri = file_uri or "stdin:"
1972 local f = Io.uri(file_uri,add_extension) 1972 local f = Io.uri(file_uri)
1973 f.exists() or <a href="#Luan.error">Luan.error</a>("file '"..file_uri.."' not found") 1973 f.exists() or <a href="#Luan.error">Luan.error</a>("file '"..file_uri.."' not found")
1974 return <a href="#Luan.load">Luan.load</a>( f.read_text(), file_uri ) 1974 return <a href="#Luan.load">Luan.load</a>( f.read_text(), file_uri )
1975 end 1975 end
1976 </pre> 1976 </pre>
1977 1977
2229 2229
2230 <p> 2230 <p>
2231 Include this library by: 2231 Include this library by:
2232 2232
2233 <pre> 2233 <pre>
2234 local Package = require "luan:Package" 2234 local Package = require "luan:Package.luan"
2235 </pre> 2235 </pre>
2236 2236
2237 <p> 2237 <p>
2238 The package library provides basic 2238 The package library provides basic
2239 facilities for loading modules in Luan. 2239 facilities for loading modules in Luan.
2251 2251
2252 <p> 2252 <p>
2253 To load a new value, <code>Package.load</code> first checks if <code>mod_uri</code> starts with "<b>java:</b>". If yes, then this is a Java class which is loaded by special Java code. 2253 To load a new value, <code>Package.load</code> first checks if <code>mod_uri</code> starts with "<b>java:</b>". If yes, then this is a Java class which is loaded by special Java code.
2254 2254
2255 <p> 2255 <p>
2256 If <code>mod_uri</code> is not a Java class, then <code>Package.load</code> tries to read the text of the file referred to by <code>mod_uri</code> (using <code>add_extension</code>=true). If the file doesn't exist, then <code>Package.load</code> returns <b>nil</b>. If the file exists, then its content is compiled into a chunk calling <a href="#Luan.load"><code>Luan.load</code></a> and passing in an empty table as the <code>env</code> value. This chunk is run passing in <code>mod_uri</code> as an argument. If the chunk returns a value other than <b>nil</b>, then that value is the value of this module. Otherwise the <code>env</code> that was passed in is the value of this module. 2256 If <code>mod_uri</code> is not a Java class, then <code>Package.load</code> tries to read the text of the file referred to by <code>mod_uri</code>. If the file doesn't exist, then <code>Package.load</code> returns <b>nil</b>. If the file exists, then its content is compiled into a chunk calling <a href="#Luan.load"><code>Luan.load</code></a> and passing in an empty table as the <code>env</code> value. This chunk is run passing in <code>mod_uri</code> as an argument. If the chunk returns a value other than <b>nil</b>, then that value is the value of this module. Otherwise the <code>env</code> that was passed in is the value of this module.
2257 2257
2258 <p> 2258 <p>
2259 If a new value for the module successful loaded, then it is stored in <code>Package.loaded[mod_uri]</code>. The value is returned. 2259 If a new value for the module successful loaded, then it is stored in <code>Package.loaded[mod_uri]</code>. The value is returned.
2260 2260
2261 2261
2286 2286
2287 <p> 2287 <p>
2288 Include this library by: 2288 Include this library by:
2289 2289
2290 <pre> 2290 <pre>
2291 local String = require "luan:String" 2291 local String = require "luan:String.luan"
2292 </pre> 2292 </pre>
2293 2293
2294 <p> 2294 <p>
2295 This library provides generic functions for string manipulation, 2295 This library provides generic functions for string manipulation,
2296 such as finding and extracting substrings, and pattern matching. 2296 such as finding and extracting substrings, and pattern matching.
2632 2632
2633 <p> 2633 <p>
2634 Include this library by: 2634 Include this library by:
2635 2635
2636 <pre> 2636 <pre>
2637 local Binary = require "luan:Binary" 2637 local Binary = require "luan:Binary.luan"
2638 </pre> 2638 </pre>
2639 2639
2640 2640
2641 <h4 heading><a name="Binary.binary" href="#Binary.binary"><code>Binary.binary (&middot;&middot;&middot;)</code></a></h4> 2641 <h4 heading><a name="Binary.binary" href="#Binary.binary"><code>Binary.binary (&middot;&middot;&middot;)</code></a></h4>
2642 2642
2669 2669
2670 <p> 2670 <p>
2671 Include this library by: 2671 Include this library by:
2672 2672
2673 <pre> 2673 <pre>
2674 local Table = require "luan:Table" 2674 local Table = require "luan:Table.luan"
2675 </pre> 2675 </pre>
2676 2676
2677 <p> 2677 <p>
2678 This library provides generic functions for table manipulation. 2678 This library provides generic functions for table manipulation.
2679 It provides all its functions inside the table <code>Table</code>. 2679 It provides all its functions inside the table <code>Table</code>.
2782 2782
2783 <p> 2783 <p>
2784 Include this library by: 2784 Include this library by:
2785 2785
2786 <pre> 2786 <pre>
2787 local Number = require "luan:Number" 2787 local Number = require "luan:Number.luan"
2788 </pre> 2788 </pre>
2789 2789
2790 2790
2791 <h4 heading><a name="Number.double" href="#Number.double"><code>Number.double (x)</code></a></h4> 2791 <h4 heading><a name="Number.double" href="#Number.double"><code>Number.double (x)</code></a></h4>
2792 <p> 2792 <p>
2823 2823
2824 <p> 2824 <p>
2825 Include this library by: 2825 Include this library by:
2826 2826
2827 <pre> 2827 <pre>
2828 local Math = require "luan:Math" 2828 local Math = require "luan:Math.luan"
2829 </pre> 2829 </pre>
2830 2830
2831 <p> 2831 <p>
2832 This library provides basic mathematical functions. 2832 This library provides basic mathematical functions.
2833 It provides all its functions and constants inside the table <code>Math</code>. 2833 It provides all its functions and constants inside the table <code>Math</code>.