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