beta-0.89.2
[luatex.git] / source / libs / lua52 / lua52-src / doc / readme.html
blob82dfe8119b6ad5dfbc86548855298a77674bd861
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 ;
15 .display {
16 word-spacing: 0.25em ;
19 dl.display dd {
20 padding-bottom: 0.2em ;
23 tt, kbd, code {
24 font-size: 12pt ;
26 </STYLE>
27 </HEAD>
29 <BODY>
31 <HR>
32 <H1>
33 <A HREF="http://www.lua.org/"><IMG SRC="logo.gif" ALT="Lua" BORDER=0></A>
34 Welcome to Lua 5.2
35 </H1>
37 <P>
38 <A HREF="#about">about</A>
39 &middot;
40 <A HREF="#install">installation</A>
41 &middot;
42 <A HREF="#changes">changes</A>
43 &middot;
44 <A HREF="#license">license</A>
45 &middot;
46 <A HREF="contents.html">reference manual</A>
48 <H2><A NAME="about">About Lua</A></H2>
50 <P>
51 Lua is a powerful, fast, lightweight, embeddable scripting language
52 developed by a
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.
57 Lua is
58 <A HREF="#license">free software</A>
59 used in many products and projects around the world.
61 <P>
62 Lua's
63 <A HREF="http://www.lua.org/">official web site</A>
64 provides complete information
65 about Lua,
66 including
68 <A HREF="http://www.lua.org/about.html">executive summary</A>
69 and
70 updated
71 <A HREF="http://www.lua.org/docs.html">documentation</A>,
72 especially the
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>
80 <P>
81 Lua is distributed in
82 <A HREF="http://www.lua.org/ftp/">source</A>
83 form.
84 You need to build it before using it.
85 Building Lua should be straightforward
86 because
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.
91 See also
92 <A HREF="#other">instructions for other systems</A>
93 and
94 <A HREF="#customization">customization options</A>.
96 <P>
97 If you don't have the time or the inclination to compile Lua yourself,
98 get a binary from
99 <A HREF="http://lua-users.org/wiki/LuaBinaries">LuaBinaries</A>.
100 Try also
101 <A HREF="http://luadist.org/">LuaDist</A>,
102 a multi-platform distribution of Lua that includes batteries.
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.
110 <OL>
111 <LI>
112 Open a terminal window and move to
113 the top-level directory, which is named <TT>lua-5.2.x</TT>.
114 The <TT>Makefile</TT> there controls both the build process and the installation process.
116 <LI>
117 Do "<KBD>make</KBD>" and see if your platform is listed.
118 The platforms currently supported are:
120 <P CLASS="display">
121 aix ansi bsd freebsd generic linux macosx mingw posix solaris
122 </P>
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,
128 ansi, in this order.
130 <LI>
131 The compilation takes only a few moments
132 and produces three files in the <TT>src</TT> directory:
133 lua (the interpreter),
134 luac (the compiler),
135 and liblua.a (the library).
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>
142 If you're running Linux and get compilation errors,
143 make sure you have installed the <TT>readline</TT> development package
144 (which is probably named <TT>libreadline-dev</TT> or <TT>readline-devel</TT>).
145 If you get link errors after that,
146 then try "<KBD>make linux MYLIBS=-ltermcap</KBD>".
148 <H3>Installing Lua</H3>
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.
156 To build and install Lua in one step, do "<KBD>make xxx install</KBD>",
157 where xxx is your platform name.
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.
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.
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>
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.
196 <H3><A NAME="customization">Customization</A></H3>
198 Three kinds of things can be customized by editing a file:
199 <UL>
200 <LI> Where and how to install Lua &mdash; edit <TT>Makefile</TT>.
201 <LI> How to build Lua &mdash; edit <TT>src/Makefile</TT>.
202 <LI> Lua features &mdash; edit <TT>src/luaconf.h</TT>.
203 </UL>
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.
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.
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.
223 <H3><A NAME="other">Building Lua on other systems</A></H3>
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:
231 <DL CLASS="display">
232 <DT>
233 library:
234 <DD>
235 lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c
236 lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c
237 ltm.c lundump.c lvm.c lzio.c
238 lauxlib.c lbaselib.c lbitlib.c lcorolib.c ldblib.c liolib.c
239 lmathlib.c loslib.c lstrlib.c ltablib.c loadlib.c linit.c
240 <DT>
241 interpreter:
242 <DD>
243 library, lua.c
244 <DT>
245 compiler:
246 <DD>
247 library, luac.c
248 </DL>
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 &mdash; 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.
263 As mentioned above, you may edit <TT>src/luaconf.h</TT> to customize
264 some features before building Lua.
266 <H2><A NAME="changes">Changes since Lua 5.1</A></H2>
269 Here are the main changes introduced in Lua 5.2.
271 <A HREF="contents.html">reference manual</A>
272 lists the
273 <A HREF="manual.html#8">incompatibilities</A> that had to be introduced.
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>
287 Here 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>
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>
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>
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>
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>
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>
369 Lua is free software distributed under the terms of the
370 <A HREF="http://www.opensource.org/licenses/mit-license.html">MIT license</A>
371 reproduced below;
372 it may be used for any purpose, including commercial purposes,
373 at absolutely no cost without having to ask us.
375 The only requirement is that if you do use Lua,
376 then you should give us credit by including the appropriate copyright notice somewhere in your product or its documentation.
378 For details, see
379 <A HREF="http://www.lua.org/license.html">this</A>.
381 <BLOCKQUOTE STYLE="padding-bottom: 0em">
382 Copyright &copy; 1994&ndash;2015 Lua.org, PUC-Rio.
385 Permission is hereby granted, free of charge, to any person obtaining a copy
386 of this software and associated documentation files (the "Software"), to deal
387 in the Software without restriction, including without limitation the rights
388 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
389 copies of the Software, and to permit persons to whom the Software is
390 furnished to do so, subject to the following conditions:
393 The above copyright notice and this permission notice shall be included in
394 all copies or substantial portions of the Software.
397 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
398 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
399 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
400 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
401 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
402 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
403 THE SOFTWARE.
404 </BLOCKQUOTE>
407 <HR>
408 <SMALL CLASS="footer">
409 Last update:
410 Mon Feb 23 22:25:08 BRT 2015
411 </SMALL>
412 <!--
413 Last change: revised for Lua 5.2.4
416 </BODY>
417 </HTML>