summaryrefslogtreecommitdiff
path: root/doc/readme.html
blob: 076dd81fad0d09e6ef79a73197f2813415daa156 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Lua 5.2 readme</TITLE>
<LINK REL="stylesheet" TYPE="text/css" HREF="lua.css">
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=iso-8859-1">
<STYLE TYPE="text/css">
blockquote, .display {
	color: black ;
	padding: 8px ;
	border: solid #a0a0a0 2px ;
	xbackground-color: #EFEFFF ;
	margin-left: 0px ;
}

.external {
	padding-right: 15px;
	background: transparent url(external.png) no-repeat center right;
}

tt, kbd, code {
	font-size: 120% ;
	xcolor: black ;
	xpadding: 4px ;
	xbackground-color: #E0E0E0 ;
}

kbd {
	color: black ;
	background-color: #E8E8E8 ;
}

.review {
	color: red ;
}

</STYLE>
</HEAD>

<BODY>

<HR>
<H1>
<A HREF="http://www.lua.org/"><IMG SRC="logo.gif" ALT="Lua" BORDER=0></A>
Welcome to Lua 5.2
</H1>

<IMG SRC="alert.png" ALIGN="absbottom">
<EM>This is a work version of Lua 5.2.
Everything may change in the final version.</EM>
<P>

<A HREF="#about">about</A>
&middot;
<A HREF="#install">installation</A>
&middot;
<A HREF="#changes">changes</A>
&middot;
<A HREF="#license">license</A>
&middot;
<A HREF="contents.html">reference manual</A>
<HR>
<P>

<H2><A NAME="about">About Lua</A></H2>

Lua is a powerful, fast, lightweight, embeddable scripting language
developed by a
<A HREF="http://www.lua.org/authors.html">team</A>
at
<A HREF="http://www.puc-rio.br/">PUC-Rio</A>,
the Pontifical Catholic University of Rio de Janeiro in Brazil.
Lua is
<A HREF="#license">free software</A>
used in many products and projects around the world.
<P>

Lua's
<A HREF="http://www.lua.org/">official web site</A>
provides complete information
about Lua,
including
an
<A HREF="http://www.lua.org/about.html">executive summary</A>
and
updated
<A HREF="http://www.lua.org/docs.html">documentation</A>,
especially the
<A HREF="http://www.lua.org/manual/5.2/">reference manual</A>,
which may differ slightly from the
<A HREF="contents.html">local copy</A>
distributed in this package.
<P>

<H2><A NAME="install">Installing Lua</A></H2>

Lua is distributed in source form.
You need to build it before using it.
This should be straightforward
because
Lua is implemented in pure ANSI C, and compiles unmodified in all known
platforms that have an ANSI C compiler.
Lua also compiles unmodified as C++.
<P>

The instructions below are for Unix-like platforms.
There are also
<A HREF="#other">instructions for other systems</A>.
See below for
<A HREF="#customization">customization options</A>.
<P>

<H3>Building Lua</H3>

In most Unix-like platforms, simply do "<KBD>make</KBD>" with a suitable target.
Here are the details.
<P>

<OL>
<LI>
Open a terminal window and move to
the top-level directory, which is named lua-5.2.
The Makefile there controls both the build process and the installation process.
<P>
<LI>
  Do "<KBD>make</KBD>" and see if your platform is listed.
  The platforms currently supported are:
<BLOCKQUOTE>
    aix ansi bsd freebsd generic linux macosx mingw posix solaris
</BLOCKQUOTE>
<P>
  If your platform is listed, just do "<KBD>make xxx</KBD>", where xxx
  is your platform name.
<P>
  If your platform is not listed, try the closest one or posix, generic,
  ansi, in this order.
<P>
<LI>
The compilation takes only a few moments
and produces three files in the src directory:
lua (the interpreter),
luac (the compiler),
and liblua.a (the library).
<P>
<LI>
  If you want to check that Lua has been built correctly, do "<KBD>make test</KBD>"
  after building Lua. This will run the interpreter on a "hello world"
  Lua program from the test directory.
  You may want to try other example programs in that directory.
</OL>
<P>

<H3>Installing Lua</H3>
  Once you have built Lua, you may want to install it in an official
  place in your system. In this case, do "<KBD>make install</KBD>". The official
  place and the way to install files are defined in Makefile. You'll
  probably need the right permissions to install files.
<P>

  If you want to build and install Lua in one step, do "<KBD>make xxx install</KBD>",
  where xxx is your platform name.
<P>

  If you want to install Lua locally, then do "<KBD>make local</KBD>".
  This will create a directory <TT>install</TT> with subdirectories
  <TT>bin</TT>, <TT>include</TT>, <TT>lib</TT>, <TT>man</TT>,
  and install Lua there as follows:
<P>

<DL CLASS="display">
<DT>
    bin:
<DD>
    lua luac
<DT>
    include:
<DD>
    lua.h luaconf.h lualib.h lauxlib.h lua.hpp
<DT>
    lib:
<DD>
    liblua.a
<DT>
    man/man1:
<DD>
    lua.1 luac.1
</DL>

  These are the only directories you need for development.
<P>

  There are man pages for
  <A HREF="lua.html">lua</A> and
  <A HREF="luac.html">luac</A>, in both nroff and html, and a
  <A HREF="contents.html">reference manual</A> in html in doc, some sample code in test, and some
  useful stuff in etc. You don't need these directories for development.
<P>

  If you want to install Lua locally, but in some other directory, do
  "<KBD>make install INSTALL_TOP=xxx</KBD>", where xxx is your chosen directory.
<P>

<H3><A NAME="customization">Customization</A></H3>
  Three kinds of things can be customized by editing a file:
<UL>
    <LI> Where and how to install Lua &mdash; edit Makefile.
    <LI> How to build Lua &mdash; edit src/Makefile.
    <LI> Lua features &mdash; edit src/luaconf.h.
</UL>
<P>

  You don't actually need to edit the Makefiles because you may set the
  relevant variables in the command line when invoking make.
<P>

  On the other hand, if you need to customize some Lua features, you'll need
  to edit src/luaconf.h before building and installing Lua.
  The edited file will be the one installed, and
  it will be used by any Lua clients that you build, to ensure consistency.
  (Further customization is possible by editing the Lua sources.)
<P>

  We strongly recommend that you enable dynamic loading. This is done
  automatically for all platforms listed above that have this feature
  and also for Windows.
<P>

<H3><A NAME="other">Building Lua on other systems</A></H3>

  If you're not using the usual Unix tools, then the instructions for
  building Lua depend on the compiler you use. You'll need to create
  projects (or whatever your compiler uses) for building the library,
  the interpreter, and the compiler, as follows:
<P>
<DL CLASS="display">
<DT>
library:
<DD>
lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c
lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c
ltm.c lundump.c lvm.c lzio.c
lauxlib.c lbaselib.c lbitlib.c ldblib.c liolib.c lmathlib.c loslib.c
ltablib.c lstrlib.c loadlib.c linit.c
<DT>
interpreter:
<DD>
  library, lua.c
<DT>
compiler:
<DD>
  library, luac.c print.c
</DL>

  If you use Visual Studio .NET, you can use <TT>etc/luavs.bat</TT> in its
  "Command Prompt".
<P>

  If all you want is to build the Lua interpreter, you may put all .c files
  in a single project, except for luac.c and print.c. Or just use <TT>etc/one.c</TT>.
<P>

  To use Lua as a library in your own programs you'll need to know how to
  create and use libraries with your compiler. Moreover, to dynamically load
  C libraries for Lua you'll need to know how to create dynamic libraries
  and you'll need to make sure that the Lua API functions are accessible to
  those dynamic libraries &mdash; but you do <EM>not</EM> want to link the Lua library
  into each dynamic library. For Unix, we recommend that the Lua library
  be linked statically into the host program and its symbols exported for
  dynamic linking; src/Makefile does this for the Lua interpreter.
  For Windows, we recommend that the Lua library be a DLL.
<P>

  As mentioned above, you may edit src/luaconf.h to customize
  some features before building Lua.
<P>

<H2><A NAME="changes">Changes since Lua 5.1</A></H2>

<IMG SRC="alert.png" ALIGN="absbottom">
<EM>Everything may change in the final version.</EM>
<P>

Here are the main changes since the previous work version:
<UL>
<LI> new <CODE>_ENV</CODE> proposal
<LI> generational collector (very experimental)
<LI> light C functions

<LI> order tag methods follow the same rules of other binary operators
<LI> <CODE>lua_absindex</CODE>
<LI> \0 in patterns
<LI> empty statement
<LI> options in <CODE>io.lines</CODE>
</UL>
<P>

Here are the main changes in Lua since its last release.
The
<A HREF="contents.html">reference manual</A>
lists the
<A HREF="manual.html#7">incompatibilities</A> that had to be introduced.
<P>

<H3>Language</H3>
<UL>
<LI> new lexical environments.
<LI> no more fenv for threads.
<LI> ephemeron tables
	(tables with weak keys only visit value when key is accessible).
<LI> yieldable pcall and metamethods.
<LI> tables honor the <CODE>__len</CODE> metamethod.
<LI> max constants per function raised to 2^26.
<LI> hex escapes in strings.
<LI> no more verification of opcode consistency.
</UL>

<H3>Libraries</H3>
<UL>
<LI> new library for bitwise operations.
<LI> new metamethods <CODE>__pairs</CODE> and <CODE>__ipairs</CODE>.
<LI> arguments for function called through <CODE>xpcall</CODE>.
<LI> optional argument to load (to control binary x text).
<LI> <CODE>loadlib</CODE> may load libraries with global names (RTLD_GLOBAL).
<LI> new function <CODE>package.searchpath</CODE>.
<LI> optional base in <CODE>math.log</CODE>.
<LI> <CODE>file:write</CODE> returns <CODE>file</CODE>.
<LI> closing a pipe returns exit status.
<LI> <CODE>os.exit</CODE> may close state.
<LI> new option 'isrunning' for <CODE>collectgarbage</CODE> and <CODE>lua_gc</CODE>.
<LI> frontier patterns.
<LI> <CODE>ipairs</CODE> now goes until #t.
</UL>

<H3>C API</H3>
<UL>
<LI> mainthread predefined in the registry.
<LI> <CODE>lua_cpcall</CODE> changed to a predefined function in the registry.
<LI> new constants <CODE>LUA_OK</CODE> and <CODE>LUA_ERRGCMM</CODE>.
<LI> new <CODE>lua_compare</CODE>, <CODE>lua_arith</CODE>, and <CODE>lua_len</CODE>.
<LI> new <CODE>lua_version</CODE> and <CODE>luaL_version</CODE>.
<LI> <CODE>lua_pushstring</CODE> and <CODE>pushlstring</CODE> return string.
<LI> new <CODE>luaL_testudata</CODE>.
<LI> new <CODE>luaL_tolstring</CODE>.
<LI> new <CODE>lua_copy</CODE>.
<LI> new <CODE>lua_upvalueid</CODE> and <CODE>lua_upvaluejoin</CODE>.
<LI> <CODE>nparams</CODE> and <CODE>isvarag</CODE> available in debug API.
</UL>

<H3>Implementation</H3>
<UL>
<LI> emergency garbage collector
	(core forces a full collection when allocation fails).
<LI> udata with finalizers are kept in a separated list for the GC.
<LI> CallInfo stack now is a linked list.
<LI> internal (immutable) version of ctypes.
<LI> parser uses much less C-stack space (no more auto arrays).
<LI> new hash for floats.
<LI> handling of non-string error messages in the standalone interpreter.
</UL>


<H2><A NAME="license">License</A></H2>
<A HREF="http://www.opensource.org/docs/definition.php">
<IMG SRC="osi-certified-72x60.png" ALIGN="right" BORDER="0" ALT="[osi certified]" xSTYLE="padding: 40px ;" hspace="10">
</A>

Lua is free software licensed under the terms of the
<A HREF="http://www.opensource.org/licenses/mit-license.html">MIT license</A>
reproduced below,
and
can be used for any purpose, including commercial purposes,
at absolutely no cost without having to ask us.

The only requirement is that if you do use Lua,
then you should give us credit by including the appropriate copyright notice somewhere in your product or its documentation.

For details and rationale, see
<A HREF="http://www.lua.org/license.html" class="external">this</A>.
<P>

<BLOCKQUOTE>
Copyright &copy; 1994&ndash;2010 Lua.org, PUC-Rio.
<P>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
<P>

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
<P>

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
<P>
</BLOCKQUOTE>
<P>

<HR>
<SMALL>
Last update:
Tue May 18 13:59:06 BRT 2010
</SMALL>
<!--
Last change: revised for Lua 5.2.0 (work3)
-->

</BODY>
</HTML>