Mercurial Hosting > luan
comparison website/src/manual.html @ 1434:56fb5cd8228d
cache compiled code in temp files
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 29 Dec 2019 15:25:07 -0700 |
parents | e48290f3d9fb |
children | d9a5405a3102 |
comparison
equal
deleted
inserted
replaced
1433:5f038be65271 | 1434:56fb5cd8228d |
---|---|
1810 end | 1810 end |
1811 </pre> | 1811 </pre> |
1812 | 1812 |
1813 | 1813 |
1814 | 1814 |
1815 <h4 heading><a name="Luan.eval" href="#Luan.eval"><code>Luan.eval (text [, source_name] [, env])</code></a></h4> | 1815 <h4 heading><a name="Luan.eval" href="#Luan.eval"><code>Luan.eval (text [, source_name [, env]])</code></a></h4> |
1816 | 1816 |
1817 <p> | 1817 <p> |
1818 Evaluates <code>text</code> as a Luan expression. | 1818 Evaluates <code>text</code> as a Luan expression. |
1819 | 1819 |
1820 <p> | 1820 <p> |
1874 end | 1874 end |
1875 </pre> | 1875 </pre> |
1876 | 1876 |
1877 | 1877 |
1878 | 1878 |
1879 <h4 heading><a name="Luan.load" href="#Luan.load"><code>Luan.load (text, source_name [, env])</code></a></h4> | 1879 <h4 heading><a name="Luan.load" href="#Luan.load"><code>Luan.load (text, [source_name [, env [, persist]]])</code></a></h4> |
1880 | 1880 |
1881 <p> | 1881 <p> |
1882 Loads a chunk. | 1882 Loads a chunk. |
1883 | 1883 |
1884 <p> | 1884 <p> |
1886 If there are no syntactic errors, | 1886 If there are no syntactic errors, |
1887 returns the compiled chunk as a function; | 1887 returns the compiled chunk as a function; |
1888 otherwise, throws an error. | 1888 otherwise, throws an error. |
1889 | 1889 |
1890 <p> | 1890 <p> |
1891 The <code>source_name</code> parameter is a string saying where the text came from. It is used to produce error messages. | 1891 The <code>source_name</code> parameter is a string saying where the text came from. It is used to produce error messages. Defaults to "load". |
1892 | 1892 |
1893 <p> | 1893 <p> |
1894 If the <code>env</code> parameter is supplied, it becomes the <code>_ENV</code> of the chunk. | 1894 If the <code>env</code> parameter is supplied, it becomes the <code>_ENV</code> of the chunk. |
1895 | 1895 |
1896 | 1896 <p> |
1897 <h4 heading><a name="Luan.load_file" href="#Luan.load_file"><code>Luan.load_file ([file_uri])</code></a></h4> | 1897 The <code>persist</code> parameter is a boolean which determines if the compiled code is persistently cached to a temporary file. Defaults to <code>false</code>. |
1898 | |
1899 | |
1900 <h4 heading><a name="Luan.load_file" href="#Luan.load_file"><code>Luan.load_file (file_uri)</code></a></h4> | |
1898 | 1901 |
1899 <p> | 1902 <p> |
1900 Similar to <a href="#Luan.load"><code>load</code></a>, | 1903 Similar to <a href="#Luan.load"><code>load</code></a>, |
1901 but gets the chunk from file <code>file_uri</code> | 1904 but gets the chunk from file <code>file_uri</code>. |
1902 or from the standard input, | 1905 <code>file_uri</code> can be a string or a uri table. |
1903 if no file uri is given. | |
1904 | |
1905 <p> | |
1906 Could be defined as: | |
1907 | |
1908 <pre> | |
1909 function Luan.load_file(file_uri) | |
1910 file_uri = file_uri or "stdin:" | |
1911 local f = Io.uri(file_uri) | |
1912 if not f.exists() then | |
1913 return nil | |
1914 end | |
1915 return <a href="#Luan.load">Luan.load</a>( f.read_text(), file_uri ) | |
1916 end | |
1917 </pre> | |
1918 | 1906 |
1919 | 1907 |
1920 <h4 heading><a name="Luan.new_error" href="#Luan.new_error"><code>Luan.new_error (message)</code></a></h4> | 1908 <h4 heading><a name="Luan.new_error" href="#Luan.new_error"><code>Luan.new_error (message)</code></a></h4> |
1921 | 1909 |
1922 <p> | 1910 <p> |