]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/lua/doc/readme.html
MFC lualoader: r326353, r328440, r328443, r329166-r329167, r329274, r329329,
[FreeBSD/FreeBSD.git] / contrib / lua / doc / readme.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>Lua 5.3 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
15 .display {
16         word-spacing: 0.25em ;
17 }
18
19 dl.display dd {
20         padding-bottom: 0.2em ;
21 }
22
23 tt, kbd, code {
24         font-size: 12pt ;
25 }
26 </STYLE>
27 </HEAD>
28
29 <BODY>
30
31 <H1>
32 <A HREF="http://www.lua.org/"><IMG SRC="logo.gif" ALT="Lua"></A>
33 Welcome to Lua 5.3
34 </H1>
35
36 <DIV CLASS="menubar">
37 <A HREF="#about">about</A>
38 &middot;
39 <A HREF="#install">installation</A>
40 &middot;
41 <A HREF="#changes">changes</A>
42 &middot;
43 <A HREF="#license">license</A>
44 &middot;
45 <A HREF="contents.html">reference manual</A>
46 </DIV>
47
48 <H2><A NAME="about">About Lua</A></H2>
49 <P>
50 Lua is a powerful, fast, lightweight, embeddable scripting language
51 developed by a
52 <A HREF="http://www.lua.org/authors.html">team</A>
53 at
54 <A HREF="http://www.puc-rio.br/">PUC-Rio</A>,
55 the Pontifical Catholic University of Rio de Janeiro in Brazil.
56 Lua is
57 <A HREF="#license">free software</A>
58 used in many products and projects around the world.
59
60 <P>
61 Lua's
62 <A HREF="http://www.lua.org/">official web site</A>
63 provides complete information
64 about Lua,
65 including
66 an
67 <A HREF="http://www.lua.org/about.html">executive summary</A>
68 and
69 updated
70 <A HREF="http://www.lua.org/docs.html">documentation</A>,
71 especially the
72 <A HREF="http://www.lua.org/manual/5.3/">reference manual</A>,
73 which may differ slightly from the
74 <A HREF="contents.html">local copy</A>
75 distributed in this package.
76
77 <H2><A NAME="install">Installing Lua</A></H2>
78 <P>
79 Lua is distributed in
80 <A HREF="http://www.lua.org/ftp/">source</A>
81 form.
82 You need to build it before using it.
83 Building Lua should be straightforward
84 because
85 Lua is implemented in pure ANSI C and compiles unmodified in all known
86 platforms that have an ANSI C compiler.
87 Lua also compiles unmodified as C++.
88 The instructions given below for building Lua are for Unix-like platforms.
89 See also
90 <A HREF="#other">instructions for other systems</A>
91 and
92 <A HREF="#customization">customization options</A>.
93
94 <P>
95 If you don't have the time or the inclination to compile Lua yourself,
96 get a binary from
97 <A HREF="http://lua-users.org/wiki/LuaBinaries">LuaBinaries</A>.
98 Try also
99 <A HREF="http://luadist.org/">LuaDist</A>,
100 a multi-platform distribution of Lua that includes batteries.
101
102 <H3>Building Lua</H3>
103 <P>
104 In most Unix-like platforms, simply do "<KBD>make</KBD>" with a suitable target.
105 Here are the details.
106
107 <OL>
108 <LI>
109 Open a terminal window and move to
110 the top-level directory, which is named <TT>lua-5.3.5</TT>.
111 The <TT>Makefile</TT> there controls both the build process and the installation process.
112 <P>
113 <LI>
114   Do "<KBD>make</KBD>" and see if your platform is listed.
115   The platforms currently supported are:
116 <P>
117 <P CLASS="display">
118    aix bsd c89 freebsd generic linux macosx mingw posix solaris
119 </P>
120 <P>
121   If your platform is listed, just do "<KBD>make xxx</KBD>", where xxx
122   is your platform name.
123 <P>
124   If your platform is not listed, try the closest one or posix, generic,
125   c89, in this order.
126 <P>
127 <LI>
128 The compilation takes only a few moments
129 and produces three files in the <TT>src</TT> directory:
130 lua (the interpreter),
131 luac (the compiler),
132 and liblua.a (the library).
133 <P>
134 <LI>
135   To check that Lua has been built correctly, do "<KBD>make test</KBD>"
136   after building Lua. This will run the interpreter and print its version.
137 </OL>
138 <P>
139 If you're running Linux and get compilation errors,
140 make sure you have installed the <TT>readline</TT> development package
141 (which is probably named <TT>libreadline-dev</TT> or <TT>readline-devel</TT>).
142 If you get link errors after that,
143 then try "<KBD>make linux MYLIBS=-ltermcap</KBD>".
144
145 <H3>Installing Lua</H3>
146 <P>
147   Once you have built Lua, you may want to install it in an official
148   place in your system. In this case, do "<KBD>make install</KBD>". The official
149   place and the way to install files are defined in the <TT>Makefile</TT>. You'll
150   probably need the right permissions to install files.
151
152 <P>
153   To build and install Lua in one step, do "<KBD>make xxx install</KBD>",
154   where xxx is your platform name.
155
156 <P>
157   To install Lua locally, do "<KBD>make local</KBD>".
158   This will create a directory <TT>install</TT> with subdirectories
159   <TT>bin</TT>, <TT>include</TT>, <TT>lib</TT>, <TT>man</TT>, <TT>share</TT>,
160   and install Lua as listed below.
161
162   To install Lua locally, but in some other directory, do
163   "<KBD>make install INSTALL_TOP=xxx</KBD>", where xxx is your chosen directory.
164   The installation starts in the <TT>src</TT> and <TT>doc</TT> directories,
165   so take care if <TT>INSTALL_TOP</TT> is not an absolute path.
166
167 <DL CLASS="display">
168 <DT>
169     bin:
170 <DD>
171     lua luac
172 <DT>
173     include:
174 <DD>
175     lua.h luaconf.h lualib.h lauxlib.h lua.hpp
176 <DT>
177     lib:
178 <DD>
179     liblua.a
180 <DT>
181     man/man1:
182 <DD>
183     lua.1 luac.1
184 </DL>
185
186 <P>
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 <TT>bin</TT> and <TT>man</TT>.
190   The files in <TT>include</TT> and <TT>lib</TT> are needed for
191   embedding Lua in C or C++ programs.
192
193 <H3><A NAME="customization">Customization</A></H3>
194 <P>
195   Three kinds of things can be customized by editing a file:
196 <UL>
197     <LI> Where and how to install Lua &mdash; edit <TT>Makefile</TT>.
198     <LI> How to build Lua &mdash; edit <TT>src/Makefile</TT>.
199     <LI> Lua features &mdash; edit <TT>src/luaconf.h</TT>.
200 </UL>
201
202 <P>
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've made.
207
208 <P>
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.
214
215 <H3><A NAME="other">Building Lua on other systems</A></H3>
216 <P>
217   If you're not using the usual Unix tools, then the instructions for
218   building Lua depend on the compiler you use. You'll need to create
219   projects (or whatever your compiler uses) for building the library,
220   the interpreter, and the compiler, as follows:
221
222 <DL CLASS="display">
223 <DT>
224 library:
225 <DD>
226 lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c
227 lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c
228 ltm.c lundump.c lvm.c lzio.c
229 lauxlib.c lbaselib.c lbitlib.c lcorolib.c ldblib.c liolib.c
230 lmathlib.c loslib.c lstrlib.c ltablib.c lutf8lib.c loadlib.c linit.c
231 <DT>
232 interpreter:
233 <DD>
234   library, lua.c
235 <DT>
236 compiler:
237 <DD>
238   library, luac.c
239 </DL>
240
241 <P>
242   To use Lua as a library in your own programs you'll need to know how to
243   create and use libraries with your compiler. Moreover, to dynamically load
244   C libraries for Lua you'll need to know how to create dynamic libraries
245   and you'll need to make sure that the Lua API functions are accessible to
246   those dynamic libraries &mdash; but <EM>don't</EM> link the Lua library
247   into each dynamic library. For Unix, we recommend that the Lua library
248   be linked statically into the host program and its symbols exported for
249   dynamic linking; <TT>src/Makefile</TT> does this for the Lua interpreter.
250   For Windows, we recommend that the Lua library be a DLL.
251   In all cases, the compiler luac should be linked statically.
252
253 <P>
254   As mentioned above, you may edit <TT>src/luaconf.h</TT> to customize
255   some features before building Lua.
256
257 <H2><A NAME="changes">Changes since Lua 5.2</A></H2>
258 <P>
259 Here are the main changes introduced in Lua 5.3.
260 The
261 <A HREF="contents.html">reference manual</A>
262 lists the
263 <A HREF="manual.html#8">incompatibilities</A> that had to be introduced.
264
265 <H3>Main changes</H3>
266 <UL>
267 <LI> integers (64-bit by default)
268 <LI> official support for 32-bit numbers
269 <LI> bitwise operators
270 <LI> basic utf-8 support
271 <LI> functions for packing and unpacking values
272
273 </UL>
274
275 Here are the other changes introduced in Lua 5.3:
276 <H3>Language</H3>
277 <UL>
278 <LI> userdata can have any Lua value as uservalue
279 <LI> floor division
280 <LI> more flexible rules for some metamethods
281 </UL>
282
283 <H3>Libraries</H3>
284 <UL>
285 <LI> <CODE>ipairs</CODE> and the table library respect metamethods
286 <LI> strip option in <CODE>string.dump</CODE>
287 <LI> table library respects metamethods
288 <LI> new function <CODE>table.move</CODE>
289 <LI> new function <CODE>string.pack</CODE>
290 <LI> new function <CODE>string.unpack</CODE>
291 <LI> new function <CODE>string.packsize</CODE>
292 </UL>
293
294 <H3>C API</H3>
295 <UL>
296 <LI> simpler API for continuation functions in C
297 <LI> <CODE>lua_gettable</CODE> and similar functions return type of resulted value
298 <LI> strip option in <CODE>lua_dump</CODE>
299 <LI> new function: <CODE>lua_geti</CODE>
300 <LI> new function: <CODE>lua_seti</CODE>
301 <LI> new function: <CODE>lua_isyieldable</CODE>
302 <LI> new function: <CODE>lua_numbertointeger</CODE>
303 <LI> new function: <CODE>lua_rotate</CODE>
304 <LI> new function: <CODE>lua_stringtonumber</CODE>
305 </UL>
306
307 <H3>Lua standalone interpreter</H3>
308 <UL>
309 <LI> can be used as calculator; no need to prefix with '='
310 <LI> <CODE>arg</CODE> table available to all code
311 </UL>
312
313 <H2><A NAME="license">License</A></H2>
314 <P>
315 <A HREF="http://www.opensource.org/docs/definition.php">
316 <IMG SRC="osi-certified-72x60.png" ALIGN="right" ALT="[osi certified]" STYLE="padding-left: 30px ;">
317 </A>
318 Lua is free software distributed under the terms of the
319 <A HREF="http://www.opensource.org/licenses/mit-license.html">MIT license</A>
320 reproduced below;
321 it may be used for any purpose, including commercial purposes,
322 at absolutely no cost without having to ask us.
323
324 The only requirement is that if you do use Lua,
325 then you should give us credit by including the appropriate copyright notice somewhere in your product or its documentation.
326
327 For details, see
328 <A HREF="http://www.lua.org/license.html">this</A>.
329
330 <BLOCKQUOTE STYLE="padding-bottom: 0em">
331 Copyright &copy; 1994&ndash;2017 Lua.org, PUC-Rio.
332
333 <P>
334 Permission is hereby granted, free of charge, to any person obtaining a copy
335 of this software and associated documentation files (the "Software"), to deal
336 in the Software without restriction, including without limitation the rights
337 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
338 copies of the Software, and to permit persons to whom the Software is
339 furnished to do so, subject to the following conditions:
340
341 <P>
342 The above copyright notice and this permission notice shall be included in
343 all copies or substantial portions of the Software.
344
345 <P>
346 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
347 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
348 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
349 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
350 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
351 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
352 THE SOFTWARE.
353 </BLOCKQUOTE>
354 <P>
355
356 <P CLASS="footer">
357 Last update:
358 Mon Jun 18 22:57:33 -03 2018
359 </P>
360 <!--
361 Last change: revised for Lua 5.3.5
362 -->
363
364 </BODY>
365 </HTML>