Mercurial Hosting > luan
comparison website/src/manual.html.luan @ 468:9b51e2413cab
documentation
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Fri, 08 May 2015 17:29:28 -0600 |
| parents | 47c7de1f2322 |
| children | 85467f95ab13 |
comparison
equal
deleted
inserted
replaced
| 467:f86bf532f87c | 468:9b51e2413cab |
|---|---|
| 81 </li> | 81 </li> |
| 82 <li><a href="#visibility">Visibility Rules</a></li> | 82 <li><a href="#visibility">Visibility Rules</a></li> |
| 83 </ul> | 83 </ul> |
| 84 </div> | 84 </div> |
| 85 | 85 |
| 86 <div margin-bottom="1em"> | |
| 87 <a href="#libs">Standard Libraries</a> | |
| 88 <ul> | |
| 89 <li><a href="#default_lib">Default Environment</a></li> | |
| 90 </ul> | |
| 91 </div> | |
| 92 | |
| 86 <hr/> | 93 <hr/> |
| 87 | 94 |
| 88 | 95 |
| 89 <h2 margin-top="1em"><a name="intro">Introduction</a></h2> | 96 <h2 margin-top="1em"><a name="intro">Introduction</a></h2> |
| 90 | 97 |
| 1799 | 1806 |
| 1800 | 1807 |
| 1801 | 1808 |
| 1802 | 1809 |
| 1803 | 1810 |
| 1804 <h1>6 – <a name="6">Standard Libraries</a></h1> | 1811 <h2 margin-top="1em"><a name="libs">Standard Libraries</a></h2> |
| 1805 | 1812 |
| 1806 <p> | 1813 <p> |
| 1807 The standard Lua libraries provide useful functions | 1814 The standard Luan libraries provide useful functions |
| 1808 that are implemented directly through the C API. | 1815 that are implemented both in Java and in Luan itself. |
| 1816 How each function is implemented shouldn't matter to the user. | |
| 1809 Some of these functions provide essential services to the language | 1817 Some of these functions provide essential services to the language |
| 1810 (e.g., <a href="#pdf-type"><code>type</code></a> and <a href="#pdf-getmetatable"><code>getmetatable</code></a>); | 1818 (e.g., <a href="#pdf-type"><tt>type</tt></a> and <a href="#pdf-getmetatable"><tt>get_metatable</tt></a>); |
| 1811 others provide access to "outside" services (e.g., I/O); | 1819 others provide access to "outside" services (e.g., I/O). |
| 1812 and others could be implemented in Lua itself, | 1820 |
| 1813 but are quite useful or have critical performance requirements that | 1821 |
| 1814 deserve an implementation in C (e.g., <a href="#pdf-table.sort"><code>table.sort</code></a>). | 1822 <h3 margin-top="1em"><a name="default_lib">Default Environment</a></h3> |
| 1815 | 1823 |
| 1816 | 1824 <p> |
| 1817 <p> | 1825 These are provided by default as local variables for any Luan code as described in <a href="#env">Environments</a>. |
| 1818 All libraries are implemented through the official C API | 1826 |
| 1819 and are provided as separate C modules. | 1827 <h4 margin-top="1em"><a name="_ENV"><tt>_ENV</tt></a></h4> |
| 1820 Currently, Lua has the following standard libraries: | 1828 |
| 1821 | 1829 <p> |
| 1822 <ul> | 1830 This is a table that holds the global variables of a module as described in <a href="#env">Environments</a>. |
| 1823 | |
| 1824 <li>basic library (<a href="#6.1">§6.1</a>);</li> | |
| 1825 | |
| 1826 <li>coroutine library (<a href="#6.2">§6.2</a>);</li> | |
| 1827 | |
| 1828 <li>package library (<a href="#6.3">§6.3</a>);</li> | |
| 1829 | |
| 1830 <li>string manipulation (<a href="#6.4">§6.4</a>);</li> | |
| 1831 | |
| 1832 <li>basic UTF-8 support (<a href="#6.5">§6.5</a>);</li> | |
| 1833 | |
| 1834 <li>table manipulation (<a href="#6.6">§6.6</a>);</li> | |
| 1835 | |
| 1836 <li>mathematical functions (<a href="#6.7">§6.7</a>) (sin, log, etc.);</li> | |
| 1837 | |
| 1838 <li>input and output (<a href="#6.8">§6.8</a>);</li> | |
| 1839 | |
| 1840 <li>operating system facilities (<a href="#6.9">§6.9</a>);</li> | |
| 1841 | |
| 1842 <li>debug facilities (<a href="#6.10">§6.10</a>).</li> | |
| 1843 | |
| 1844 </ul><p> | |
| 1845 Except for the basic and the package libraries, | |
| 1846 each library provides all its functions as fields of a global table | |
| 1847 or as methods of its objects. | |
| 1848 | |
| 1849 | |
| 1850 <p> | |
| 1851 To have access to these libraries, | |
| 1852 the C host program should call the <a href="#luaL_openlibs"><code>luaL_openlibs</code></a> function, | |
| 1853 which opens all standard libraries. | |
| 1854 Alternatively, | |
| 1855 the host program can open them individually by using | |
| 1856 <a href="#luaL_requiref"><code>luaL_requiref</code></a> to call | |
| 1857 <a name="pdf-luaopen_base"><code>luaopen_base</code></a> (for the basic library), | |
| 1858 <a name="pdf-luaopen_package"><code>luaopen_package</code></a> (for the package library), | |
| 1859 <a name="pdf-luaopen_coroutine"><code>luaopen_coroutine</code></a> (for the coroutine library), | |
| 1860 <a name="pdf-luaopen_string"><code>luaopen_string</code></a> (for the string library), | |
| 1861 <a name="pdf-luaopen_utf8"><code>luaopen_utf8</code></a> (for the UTF8 library), | |
| 1862 <a name="pdf-luaopen_table"><code>luaopen_table</code></a> (for the table library), | |
| 1863 <a name="pdf-luaopen_math"><code>luaopen_math</code></a> (for the mathematical library), | |
| 1864 <a name="pdf-luaopen_io"><code>luaopen_io</code></a> (for the I/O library), | |
| 1865 <a name="pdf-luaopen_os"><code>luaopen_os</code></a> (for the operating system library), | |
| 1866 and <a name="pdf-luaopen_debug"><code>luaopen_debug</code></a> (for the debug library). | |
| 1867 These functions are declared in <a name="pdf-lualib.h"><code>lualib.h</code></a>. | |
| 1868 | 1831 |
| 1869 | 1832 |
| 1870 | 1833 |
| 1871 <h2>6.1 – <a name="6.1">Basic Functions</a></h2> | 1834 <h2>6.1 – <a name="6.1">Basic Functions</a></h2> |
| 1872 | 1835 |
