1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
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">
9 border: solid #a0a0a0 2px ;
16 word-spacing: 0.25em ;
20 padding-bottom: 0.2em ;
33 <A HREF="http://www.lua.org/"><IMG SRC="logo.gif" ALT="Lua" BORDER=0></A>
38 <A HREF="#about">about</A>
40 <A HREF="#install">installation</A>
42 <A HREF="#changes">changes</A>
44 <A HREF="#license">license</A>
46 <A HREF="contents.html">reference manual</A>
48 <H2><A NAME="about">About Lua</A></H2>
51 Lua is a powerful, fast, lightweight, embeddable scripting language
53 <A HREF="http://www.lua.org/authors.html">team</A>
55 <A HREF="http://www.puc-rio.br/">PUC-Rio</A>,
56 the Pontifical Catholic University of Rio de Janeiro in Brazil.
58 <A HREF="#license">free software</A>
59 used in many products and projects around the world.
63 <A HREF="http://www.lua.org/">official web site</A>
64 provides complete information
68 <A HREF="http://www.lua.org/about.html">executive summary</A>
71 <A HREF="http://www.lua.org/docs.html">documentation</A>,
73 <A HREF="http://www.lua.org/manual/5.2/">reference manual</A>,
74 which may differ slightly from the
75 <A HREF="contents.html">local copy</A>
76 distributed in this package.
78 <H2><A NAME="install">Installing Lua</A></H2>
82 <A HREF="http://www.lua.org/ftp/">source</A>
84 You need to build it before using it.
85 Building Lua should be straightforward
87 Lua is implemented in pure ANSI C and compiles unmodified in all known
88 platforms that have an ANSI C compiler.
89 Lua also compiles unmodified as C++.
90 The instructions given below for building Lua are for Unix-like platforms.
92 <A HREF="#other">instructions for other systems</A>
94 <A HREF="#customization">customization options</A>.
97 If you don't have the time or the inclination to compile Lua yourself,
99 <A HREF="http://lua-users.org/wiki/LuaBinaries">LuaBinaries</A>.
101 <A HREF="http://luaforwindows.luaforge.net/">Lua for Windows</A>,
102 an easy-to-use distribution of Lua that includes many useful libraries.
104 <H3>Building Lua</H3>
107 In most Unix-like platforms, simply do "<KBD>make</KBD>" with a suitable target.
108 Here are the details.
112 Open a terminal window and move to
113 the top-level directory, which is named <TT>lua-5.2.3</TT>.
114 The Makefile there controls both the build process and the installation process.
117 Do "<KBD>make</KBD>" and see if your platform is listed.
118 The platforms currently supported are:
121 aix ansi bsd freebsd generic linux macosx mingw posix solaris
124 If your platform is listed, just do "<KBD>make xxx</KBD>", where xxx
125 is your platform name.
127 If your platform is not listed, try the closest one or posix, generic,
131 The compilation takes only a few moments
132 and produces three files in the <TT>src</TT> directory:
133 lua (the interpreter),
135 and liblua.a (the library).
138 To check that Lua has been built correctly, do "<KBD>make test</KBD>"
139 after building Lua. This will run the interpreter and print its version string.
142 If you're running Linux and get compilation errors,
143 make sure you have installed the <TT>readline</TT> development package.
144 If you get link errors after that,
145 then try "<KBD>make linux MYLIBS=-ltermcap</KBD>".
147 <H3>Installing Lua</H3>
149 Once you have built Lua, you may want to install it in an official
150 place in your system. In this case, do "<KBD>make install</KBD>". The official
151 place and the way to install files are defined in the Makefile. You'll
152 probably need the right permissions to install files.
155 To build and install Lua in one step, do "<KBD>make xxx install</KBD>",
156 where xxx is your platform name.
159 To install Lua locally, do "<KBD>make local</KBD>".
160 This will create a directory <TT>install</TT> with subdirectories
161 <TT>bin</TT>, <TT>include</TT>, <TT>lib</TT>, <TT>man</TT>,
162 and install Lua as listed below.
164 To install Lua locally, but in some other directory, do
165 "<KBD>make install INSTALL_TOP=xxx</KBD>", where xxx is your chosen directory.
175 lua.h luaconf.h lualib.h lauxlib.h lua.hpp
187 These are the only directories you need for development.
188 If you only want to run Lua programs,
189 you only need the files in bin and man.
190 The files in include and lib are needed for
191 embedding Lua in C or C++ programs.
193 <H3><A NAME="customization">Customization</A></H3>
195 Three kinds of things can be customized by editing a file:
197 <LI> Where and how to install Lua — edit <TT>Makefile</TT>.
198 <LI> How to build Lua — edit <TT>src/Makefile</TT>.
199 <LI> Lua features — edit <TT>src/luaconf.h</TT>.
203 You don't actually need to edit the Makefiles because you may set the
204 relevant variables in the command line when invoking make.
205 Nevertheless, it's probably best to edit and save the Makefiles to
206 record the changes you need.
209 On the other hand, if you need to customize some Lua features, you'll need
210 to edit <TT>src/luaconf.h</TT> before building and installing Lua.
211 The edited file will be the one installed, and
212 it will be used by any Lua clients that you build, to ensure consistency.
213 Further customization is available to experts by editing the Lua sources.
216 We strongly recommend that you enable dynamic loading in <TT>src/luaconf.h</TT>.
217 This is done automatically for all platforms listed above that have
218 this feature and also for Windows.
220 <H3><A NAME="other">Building Lua on other systems</A></H3>
223 If you're not using the usual Unix tools, then the instructions for
224 building Lua depend on the compiler you use. You'll need to create
225 projects (or whatever your compiler uses) for building the library,
226 the interpreter, and the compiler, as follows:
232 lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c
233 lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c
234 ltm.c lundump.c lvm.c lzio.c
235 lauxlib.c lbaselib.c lbitlib.c lcorolib.c ldblib.c liolib.c
236 lmathlib.c loslib.c lstrlib.c ltablib.c loadlib.c linit.c
248 To use Lua as a library in your own programs you'll need to know how to
249 create and use libraries with your compiler. Moreover, to dynamically load
250 C libraries for Lua you'll need to know how to create dynamic libraries
251 and you'll need to make sure that the Lua API functions are accessible to
252 those dynamic libraries — but <EM>don't</EM> link the Lua library
253 into each dynamic library. For Unix, we recommend that the Lua library
254 be linked statically into the host program and its symbols exported for
255 dynamic linking; <TT>src/Makefile</TT> does this for the Lua interpreter.
256 For Windows, we recommend that the Lua library be a DLL.
259 As mentioned above, you may edit <TT>src/luaconf.h</TT> to customize
260 some features before building Lua.
262 <H2><A NAME="changes">Changes since Lua 5.1</A></H2>
265 Here are the main changes introduced in Lua 5.2.
267 <A HREF="contents.html">reference manual</A>
269 <A HREF="manual.html#8">incompatibilities</A> that had to be introduced.
271 <H3>Main changes</H3>
273 <LI> yieldable pcall and metamethods
274 <LI> new lexical scheme for globals
275 <LI> ephemeron tables
276 <LI> new library for bitwise operations
277 <LI> light C functions
278 <LI> emergency garbage collector
279 <LI> <CODE>goto</CODE> statement
280 <LI> finalizers for tables
283 Here are the other changes introduced in Lua 5.2:
286 <LI> no more fenv for threads or functions
287 <LI> tables honor the <CODE>__len</CODE> metamethod
288 <LI> hex and <CODE>\z</CODE> escapes in strings
289 <LI> support for hexadecimal floats
290 <LI> order metamethods work for different types
291 <LI> no more verification of opcode consistency
292 <LI> hook event "tail return" replaced by "tail call"
294 <LI> <CODE>break</CODE> statement may appear in the middle of a block
299 <LI> arguments for function called through <CODE>xpcall</CODE>
300 <LI> optional 'mode' argument to load and loadfile (to control binary x text)
301 <LI> optional 'env' argument to load and loadfile (environment for loaded chunk)
302 <LI> <CODE>loadlib</CODE> may load libraries with global names (RTLD_GLOBAL)
303 <LI> new function <CODE>package.searchpath</CODE>
304 <LI> modules receive their paths when loaded
305 <LI> optional base in <CODE>math.log</CODE>
306 <LI> optional separator in <CODE>string.rep</CODE>
307 <LI> <CODE>file:write</CODE> returns <CODE>file</CODE>
308 <LI> closing a pipe returns exit status
309 <LI> <CODE>os.exit</CODE> may close state
310 <LI> new metamethods <CODE>__pairs</CODE> and <CODE>__ipairs</CODE>
311 <LI> new option 'isrunning' for <CODE>collectgarbage</CODE> and <CODE>lua_gc</CODE>
312 <LI> frontier patterns
313 <LI> <CODE>\0</CODE> in patterns
314 <LI> new option <CODE>*L</CODE> for <CODE>io.read</CODE>
315 <LI> options for <CODE>io.lines</CODE>
316 <LI> <CODE>debug.getlocal</CODE> can access function varargs
321 <LI> main thread predefined in the registry
323 <CODE>lua_absindex</CODE>,
324 <CODE>lua_arith</CODE>,
325 <CODE>lua_compare</CODE>,
326 <CODE>lua_copy</CODE>,
327 <CODE>lua_len</CODE>,
328 <CODE>lua_rawgetp</CODE>,
329 <CODE>lua_rawsetp</CODE>,
330 <CODE>lua_upvalueid</CODE>,
331 <CODE>lua_upvaluejoin</CODE>,
332 <CODE>lua_version</CODE>.
334 <CODE>luaL_checkversion</CODE>,
335 <CODE>luaL_setmetatable</CODE>,
336 <CODE>luaL_testudata</CODE>,
337 <CODE>luaL_tolstring</CODE>.
338 <LI> <CODE>lua_pushstring</CODE> and <CODE>pushlstring</CODE> return string
339 <LI> <CODE>nparams</CODE> and <CODE>isvararg</CODE> available in debug API
340 <LI> new <CODE>lua_Unsigned</CODE>
343 <H3>Implementation</H3>
345 <LI> max constants per function raised to 2<SUP>26</SUP>
346 <LI> generational mode for garbage collection (experimental)
347 <LI> NaN trick (experimental)
348 <LI> internal (immutable) version of ctypes
349 <LI> simpler implementation for string buffers
350 <LI> parser uses much less C-stack space (no more auto arrays)
353 <H3>Lua standalone interpreter</H3>
355 <LI> new <CODE>-E</CODE> option to avoid environment variables
356 <LI> handling of non-string error messages
359 <H2><A NAME="license">License</A></H2>
360 <A HREF="http://www.opensource.org/docs/definition.php">
361 <IMG SRC="osi-certified-72x60.png" ALIGN="right" BORDER="0" ALT="[osi certified]" STYLE="padding-left: 30px ;">
365 Lua is free software distributed under the terms of the
366 <A HREF="http://www.opensource.org/licenses/mit-license.html">MIT license</A>
368 it may be used for any purpose, including commercial purposes,
369 at absolutely no cost without having to ask us.
371 The only requirement is that if you do use Lua,
372 then you should give us credit by including the appropriate copyright notice somewhere in your product or its documentation.
375 <A HREF="http://www.lua.org/license.html">this</A>.
377 <BLOCKQUOTE STYLE="padding-bottom: 0em">
378 Copyright © 1994–2013 Lua.org, PUC-Rio.
381 Permission is hereby granted, free of charge, to any person obtaining a copy
382 of this software and associated documentation files (the "Software"), to deal
383 in the Software without restriction, including without limitation the rights
384 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
385 copies of the Software, and to permit persons to whom the Software is
386 furnished to do so, subject to the following conditions:
389 The above copyright notice and this permission notice shall be included in
390 all copies or substantial portions of the Software.
393 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
394 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
395 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
396 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
397 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
398 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
404 <SMALL CLASS="footer">
406 Sat Nov 9 22:39:16 BRST 2013
409 Last change: revised for Lua 5.2.3