readme.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <HTML>
  3. <HEAD>
  4. <TITLE>Lua 5.2 readme</TITLE>
  5. <LINK REL="stylesheet" TYPE="text/css" HREF="lua.css">
  6. <META HTTP-EQUIV="content-type" CONTENT="text/html; charset=iso-8859-1">
  7. <STYLE TYPE="text/css">
  8. blockquote, .display {
  9. border: solid #a0a0a0 2px ;
  10. border-radius: 8px ;
  11. padding: 1em ;
  12. margin: 0px ;
  13. }
  14. .display {
  15. word-spacing: 0.25em ;
  16. }
  17. dl.display dd {
  18. padding-bottom: 0.2em ;
  19. }
  20. tt, kbd, code {
  21. font-size: 12pt ;
  22. }
  23. </STYLE>
  24. </HEAD>
  25. <BODY>
  26. <HR>
  27. <H1>
  28. <A HREF="http://www.lua.org/"><IMG SRC="logo.gif" ALT="Lua" BORDER=0></A>
  29. Welcome to Lua 5.2
  30. </H1>
  31. <P>
  32. <A HREF="#about">about</A>
  33. &middot;
  34. <A HREF="#install">installation</A>
  35. &middot;
  36. <A HREF="#changes">changes</A>
  37. &middot;
  38. <A HREF="#license">license</A>
  39. &middot;
  40. <A HREF="contents.html">reference manual</A>
  41. <H2><A NAME="about">About Lua</A></H2>
  42. <P>
  43. Lua is a powerful, fast, lightweight, embeddable scripting language
  44. developed by a
  45. <A HREF="http://www.lua.org/authors.html">team</A>
  46. at
  47. <A HREF="http://www.puc-rio.br/">PUC-Rio</A>,
  48. the Pontifical Catholic University of Rio de Janeiro in Brazil.
  49. Lua is
  50. <A HREF="#license">free software</A>
  51. used in many products and projects around the world.
  52. <P>
  53. Lua's
  54. <A HREF="http://www.lua.org/">official web site</A>
  55. provides complete information
  56. about Lua,
  57. including
  58. an
  59. <A HREF="http://www.lua.org/about.html">executive summary</A>
  60. and
  61. updated
  62. <A HREF="http://www.lua.org/docs.html">documentation</A>,
  63. especially the
  64. <A HREF="http://www.lua.org/manual/5.2/">reference manual</A>,
  65. which may differ slightly from the
  66. <A HREF="contents.html">local copy</A>
  67. distributed in this package.
  68. <H2><A NAME="install">Installing Lua</A></H2>
  69. <P>
  70. Lua is distributed in
  71. <A HREF="http://www.lua.org/ftp/">source</A>
  72. form.
  73. You need to build it before using it.
  74. Building Lua should be straightforward
  75. because
  76. Lua is implemented in pure ANSI C and compiles unmodified in all known
  77. platforms that have an ANSI C compiler.
  78. Lua also compiles unmodified as C++.
  79. The instructions given below for building Lua are for Unix-like platforms.
  80. See also
  81. <A HREF="#other">instructions for other systems</A>
  82. and
  83. <A HREF="#customization">customization options</A>.
  84. <P>
  85. If you don't have the time or the inclination to compile Lua yourself,
  86. get a binary from
  87. <A HREF="http://lua-users.org/wiki/LuaBinaries">LuaBinaries</A>.
  88. Try also
  89. <A HREF="http://luadist.org/">LuaDist</A>,
  90. a multi-platform distribution of Lua that includes batteries.
  91. <H3>Building Lua</H3>
  92. <P>
  93. In most Unix-like platforms, simply do "<KBD>make</KBD>" with a suitable target.
  94. Here are the details.
  95. <OL>
  96. <LI>
  97. Open a terminal window and move to
  98. the top-level directory, which is named <TT>lua-5.2.x</TT>.
  99. The <TT>Makefile</TT> there controls both the build process and the installation process.
  100. <P>
  101. <LI>
  102. Do "<KBD>make</KBD>" and see if your platform is listed.
  103. The platforms currently supported are:
  104. <P>
  105. <P CLASS="display">
  106. aix ansi bsd freebsd generic linux macosx mingw posix solaris
  107. </P>
  108. <P>
  109. If your platform is listed, just do "<KBD>make xxx</KBD>", where xxx
  110. is your platform name.
  111. <P>
  112. If your platform is not listed, try the closest one or posix, generic,
  113. ansi, in this order.
  114. <P>
  115. <LI>
  116. The compilation takes only a few moments
  117. and produces three files in the <TT>src</TT> directory:
  118. lua (the interpreter),
  119. luac (the compiler),
  120. and liblua.a (the library).
  121. <P>
  122. <LI>
  123. To check that Lua has been built correctly, do "<KBD>make test</KBD>"
  124. after building Lua. This will run the interpreter and print its version.
  125. </OL>
  126. <P>
  127. If you're running Linux and get compilation errors,
  128. make sure you have installed the <TT>readline</TT> development package
  129. (which is probably named <TT>libreadline-dev</TT> or <TT>readline-devel</TT>).
  130. If you get link errors after that,
  131. then try "<KBD>make linux MYLIBS=-ltermcap</KBD>".
  132. <H3>Installing Lua</H3>
  133. <P>
  134. Once you have built Lua, you may want to install it in an official
  135. place in your system. In this case, do "<KBD>make install</KBD>". The official
  136. place and the way to install files are defined in the <TT>Makefile</TT>. You'll
  137. probably need the right permissions to install files.
  138. <P>
  139. To build and install Lua in one step, do "<KBD>make xxx install</KBD>",
  140. where xxx is your platform name.
  141. <P>
  142. To install Lua locally, do "<KBD>make local</KBD>".
  143. This will create a directory <TT>install</TT> with subdirectories
  144. <TT>bin</TT>, <TT>include</TT>, <TT>lib</TT>, <TT>man</TT>, <TT>share</TT>,
  145. and install Lua as listed below.
  146. To install Lua locally, but in some other directory, do
  147. "<KBD>make install INSTALL_TOP=xxx</KBD>", where xxx is your chosen directory.
  148. The installation starts in the <TT>src</TT> and <TT>doc</TT> directories,
  149. so take care if <TT>INSTALL_TOP</TT> is not an absolute path.
  150. <DL CLASS="display">
  151. <DT>
  152. bin:
  153. <DD>
  154. lua luac
  155. <DT>
  156. include:
  157. <DD>
  158. lua.h luaconf.h lualib.h lauxlib.h lua.hpp
  159. <DT>
  160. lib:
  161. <DD>
  162. liblua.a
  163. <DT>
  164. man/man1:
  165. <DD>
  166. lua.1 luac.1
  167. </DL>
  168. <P>
  169. These are the only directories you need for development.
  170. If you only want to run Lua programs,
  171. you only need the files in <TT>bin</TT> and <TT>man</TT>.
  172. The files in <TT>include</TT> and <TT>lib</TT> are needed for
  173. embedding Lua in C or C++ programs.
  174. <H3><A NAME="customization">Customization</A></H3>
  175. <P>
  176. Three kinds of things can be customized by editing a file:
  177. <UL>
  178. <LI> Where and how to install Lua &mdash; edit <TT>Makefile</TT>.
  179. <LI> How to build Lua &mdash; edit <TT>src/Makefile</TT>.
  180. <LI> Lua features &mdash; edit <TT>src/luaconf.h</TT>.
  181. </UL>
  182. <P>
  183. You don't actually need to edit the Makefiles because you may set the
  184. relevant variables in the command line when invoking make.
  185. Nevertheless, it's probably best to edit and save the Makefiles to
  186. record the changes you've made.
  187. <P>
  188. On the other hand, if you need to customize some Lua features, you'll need
  189. to edit <TT>src/luaconf.h</TT> before building and installing Lua.
  190. The edited file will be the one installed, and
  191. it will be used by any Lua clients that you build, to ensure consistency.
  192. Further customization is available to experts by editing the Lua sources.
  193. <P>
  194. We strongly recommend that you enable dynamic loading in <TT>src/luaconf.h</TT>.
  195. This is done automatically for all platforms listed above that have
  196. this feature and also for Windows.
  197. <H3><A NAME="other">Building Lua on other systems</A></H3>
  198. <P>
  199. If you're not using the usual Unix tools, then the instructions for
  200. building Lua depend on the compiler you use. You'll need to create
  201. projects (or whatever your compiler uses) for building the library,
  202. the interpreter, and the compiler, as follows:
  203. <DL CLASS="display">
  204. <DT>
  205. library:
  206. <DD>
  207. lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c
  208. lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c
  209. ltm.c lundump.c lvm.c lzio.c
  210. lauxlib.c lbaselib.c lbitlib.c lcorolib.c ldblib.c liolib.c
  211. lmathlib.c loslib.c lstrlib.c ltablib.c loadlib.c linit.c
  212. <DT>
  213. interpreter:
  214. <DD>
  215. library, lua.c
  216. <DT>
  217. compiler:
  218. <DD>
  219. library, luac.c
  220. </DL>
  221. <P>
  222. To use Lua as a library in your own programs you'll need to know how to
  223. create and use libraries with your compiler. Moreover, to dynamically load
  224. C libraries for Lua you'll need to know how to create dynamic libraries
  225. and you'll need to make sure that the Lua API functions are accessible to
  226. those dynamic libraries &mdash; but <EM>don't</EM> link the Lua library
  227. into each dynamic library. For Unix, we recommend that the Lua library
  228. be linked statically into the host program and its symbols exported for
  229. dynamic linking; <TT>src/Makefile</TT> does this for the Lua interpreter.
  230. For Windows, we recommend that the Lua library be a DLL.
  231. In all cases, the compiler luac should be linked statically.
  232. <P>
  233. As mentioned above, you may edit <TT>src/luaconf.h</TT> to customize
  234. some features before building Lua.
  235. <H2><A NAME="changes">Changes since Lua 5.1</A></H2>
  236. <P>
  237. Here are the main changes introduced in Lua 5.2.
  238. The
  239. <A HREF="contents.html">reference manual</A>
  240. lists the
  241. <A HREF="manual.html#8">incompatibilities</A> that had to be introduced.
  242. <H3>Main changes</H3>
  243. <UL>
  244. <LI> yieldable pcall and metamethods
  245. <LI> new lexical scheme for globals
  246. <LI> ephemeron tables
  247. <LI> new library for bitwise operations
  248. <LI> light C functions
  249. <LI> emergency garbage collector
  250. <LI> <CODE>goto</CODE> statement
  251. <LI> finalizers for tables
  252. </UL>
  253. Here are the other changes introduced in Lua 5.2:
  254. <H3>Language</H3>
  255. <UL>
  256. <LI> no more fenv for threads or functions
  257. <LI> tables honor the <CODE>__len</CODE> metamethod
  258. <LI> hex and <CODE>\z</CODE> escapes in strings
  259. <LI> support for hexadecimal floats
  260. <LI> order metamethods work for different types
  261. <LI> no more verification of opcode consistency
  262. <LI> hook event "tail return" replaced by "tail call"
  263. <LI> empty statement
  264. <LI> <CODE>break</CODE> statement may appear in the middle of a block
  265. </UL>
  266. <H3>Libraries</H3>
  267. <UL>
  268. <LI> arguments for function called through <CODE>xpcall</CODE>
  269. <LI> optional 'mode' argument to load and loadfile (to control binary x text)
  270. <LI> optional 'env' argument to load and loadfile (environment for loaded chunk)
  271. <LI> <CODE>loadlib</CODE> may load libraries with global names (RTLD_GLOBAL)
  272. <LI> new function <CODE>package.searchpath</CODE>
  273. <LI> modules receive their paths when loaded
  274. <LI> optional base in <CODE>math.log</CODE>
  275. <LI> optional separator in <CODE>string.rep</CODE>
  276. <LI> <CODE>file:write</CODE> returns <CODE>file</CODE>
  277. <LI> closing a pipe returns exit status
  278. <LI> <CODE>os.exit</CODE> may close state
  279. <LI> new metamethods <CODE>__pairs</CODE> and <CODE>__ipairs</CODE>
  280. <LI> new option 'isrunning' for <CODE>collectgarbage</CODE> and <CODE>lua_gc</CODE>
  281. <LI> frontier patterns
  282. <LI> <CODE>\0</CODE> in patterns
  283. <LI> new option <CODE>*L</CODE> for <CODE>io.read</CODE>
  284. <LI> options for <CODE>io.lines</CODE>
  285. <LI> <CODE>debug.getlocal</CODE> can access function varargs
  286. </UL>
  287. <H3>C API</H3>
  288. <UL>
  289. <LI> main thread predefined in the registry
  290. <LI> new functions
  291. <CODE>lua_absindex</CODE>,
  292. <CODE>lua_arith</CODE>,
  293. <CODE>lua_compare</CODE>,
  294. <CODE>lua_copy</CODE>,
  295. <CODE>lua_len</CODE>,
  296. <CODE>lua_rawgetp</CODE>,
  297. <CODE>lua_rawsetp</CODE>,
  298. <CODE>lua_upvalueid</CODE>,
  299. <CODE>lua_upvaluejoin</CODE>,
  300. <CODE>lua_version</CODE>.
  301. <LI> new functions
  302. <CODE>luaL_checkversion</CODE>,
  303. <CODE>luaL_setmetatable</CODE>,
  304. <CODE>luaL_testudata</CODE>,
  305. <CODE>luaL_tolstring</CODE>.
  306. <LI> <CODE>lua_pushstring</CODE> and <CODE>pushlstring</CODE> return string
  307. <LI> <CODE>nparams</CODE> and <CODE>isvararg</CODE> available in debug API
  308. <LI> new <CODE>lua_Unsigned</CODE>
  309. </UL>
  310. <H3>Implementation</H3>
  311. <UL>
  312. <LI> max constants per function raised to 2<SUP>26</SUP>
  313. <LI> generational mode for garbage collection (experimental)
  314. <LI> NaN trick (experimental)
  315. <LI> internal (immutable) version of ctypes
  316. <LI> simpler implementation for string buffers
  317. <LI> parser uses much less C-stack space (no more auto arrays)
  318. </UL>
  319. <H3>Lua standalone interpreter</H3>
  320. <UL>
  321. <LI> new <CODE>-E</CODE> option to avoid environment variables
  322. <LI> handling of non-string error messages
  323. </UL>
  324. <H2><A NAME="license">License</A></H2>
  325. <A HREF="http://www.opensource.org/docs/definition.php">
  326. <IMG SRC="osi-certified-72x60.png" ALIGN="right" BORDER="0" ALT="[osi certified]" STYLE="padding-left: 30px ;">
  327. </A>
  328. <P>
  329. Lua is free software distributed under the terms of the
  330. <A HREF="http://www.opensource.org/licenses/mit-license.html">MIT license</A>
  331. reproduced below;
  332. it may be used for any purpose, including commercial purposes,
  333. at absolutely no cost without having to ask us.
  334. The only requirement is that if you do use Lua,
  335. then you should give us credit by including the appropriate copyright notice somewhere in your product or its documentation.
  336. For details, see
  337. <A HREF="http://www.lua.org/license.html">this</A>.
  338. <BLOCKQUOTE STYLE="padding-bottom: 0em">
  339. Copyright &copy; 1994&ndash;2015 Lua.org, PUC-Rio.
  340. <P>
  341. Permission is hereby granted, free of charge, to any person obtaining a copy
  342. of this software and associated documentation files (the "Software"), to deal
  343. in the Software without restriction, including without limitation the rights
  344. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  345. copies of the Software, and to permit persons to whom the Software is
  346. furnished to do so, subject to the following conditions:
  347. <P>
  348. The above copyright notice and this permission notice shall be included in
  349. all copies or substantial portions of the Software.
  350. <P>
  351. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  352. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  353. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  354. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  355. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  356. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  357. THE SOFTWARE.
  358. </BLOCKQUOTE>
  359. <P>
  360. <HR>
  361. <SMALL CLASS="footer">
  362. Last update:
  363. Mon Feb 23 22:25:08 BRT 2015
  364. </SMALL>
  365. <!--
  366. Last change: revised for Lua 5.2.4
  367. -->
  368. </BODY>
  369. </HTML>