Debian Codegraph @

doc/readme.html

raw
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>Lua 5.4 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="https://www.lua.org/"><IMG SRC="logo.gif" ALT="Lua"></A>
33 Welcome to Lua 5.4
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, efficient, lightweight, embeddable scripting language
51 developed by a
52 <A HREF="https://www.lua.org/authors.html">team</A>
53 at
54 <A HREF="https://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
59 <A HREF="https://www.lua.org/uses.html">many products and projects</A>
60 around the world.
61
62 <P>
63 Lua's
64 <A HREF="https://www.lua.org/">official website</A>
65 provides complete information
66 about Lua,
67 including
68 an
69 <A HREF="https://www.lua.org/about.html">executive summary</A>,
70 tips on
71 <A HREF="https://www.lua.org/start.html">getting started</A>,
72 and
73 updated
74 <A HREF="https://www.lua.org/docs.html">documentation</A>,
75 especially the
76 <A HREF="https://www.lua.org/manual/5.4/">reference manual</A>,
77 which may differ slightly from the
78 <A HREF="contents.html">local copy</A>
79 distributed in this package.
80
81 <H2><A NAME="install">Installing Lua</A></H2>
82 <P>
83 Lua is distributed in
84 <A HREF="https://www.lua.org/ftp/">source</A>
85 form.
86 You need to build it before using it.
87 Building Lua should be straightforward
88 because
89 Lua is implemented in pure ANSI C and compiles unmodified in all known
90 platforms that have an ANSI C compiler.
91 Lua also compiles unmodified as C++.
92 The instructions given below for building Lua are for Unix-like platforms,
93 such as Linux and macOS.
94 See also
95 <A HREF="#other">instructions for other systems</A>
96 and
97 <A HREF="#customization">customization options</A>.
98
99 <P>
100 If you don't have the time or the inclination to compile Lua yourself,
101 get a binary from
102 <A HREF="https://luabinaries.sourceforge.net">LuaBinaries</A>.
103
104 <H3>Building Lua</H3>
105 <P>
106 In most common Unix-like platforms, simply do "<KBD>make</KBD>".
107 Here are the details.
108
109 <OL>
110 <LI>
111 Open a terminal window and move to
112 the top-level directory, which is named <TT>lua-5.4.8</TT>.
113 The <TT>Makefile</TT> there controls both the build process and the installation process.
114 <P>
115 <LI>
116 Do "<KBD>make</KBD>". The <TT>Makefile</TT> will guess your platform and build Lua for it.
117 <P>
118 <LI>
119 If the guess failed, do "<KBD>make help</KBD>" and see if your platform is listed.
120 The platforms currently supported are:
121 <P>
122 <P CLASS="display">
123 guess aix bsd c89 freebsd generic ios linux linux-readline macosx mingw posix solaris
124 </P>
125 <P>
126 If your platform is listed, just do "<KBD>make xxx</KBD>", where xxx
127 is your platform name.
128 <P>
129 If your platform is not listed, try the closest one or posix, generic,
130 c89, in this order.
131 <P>
132 <LI>
133 The compilation takes only a few moments
134 and produces three files in the <TT>src</TT> directory:
135 lua (the interpreter),
136 luac (the compiler),
137 and liblua.a (the library).
138 <P>
139 <LI>
140 To check that Lua has been built correctly, do "<KBD>make test</KBD>"
141 after building Lua. This will run the interpreter and print its version.
142 </OL>
143 <P>
144 If you're running Linux, try "<KBD>make linux-readline</KBD>" to build the interactive Lua interpreter with handy line-editing and history capabilities.
145 If you get compilation errors,
146 make sure you have installed the <TT>readline</TT> development package
147 (which is probably named <TT>libreadline-dev</TT> or <TT>readline-devel</TT>).
148 If you get link errors after that,
149 then try "<KBD>make linux-readline MYLIBS=-ltermcap</KBD>".
150
151 <H3>Installing Lua</H3>
152 <P>
153 Once you have built Lua, you may want to install it in an official
154 place in your system. In this case, do "<KBD>make install</KBD>". The official
155 place and the way to install files are defined in the <TT>Makefile</TT>. You'll
156 probably need the right permissions to install files, and so may need to do "<KBD>sudo make install</KBD>".
157
158 <P>
159 To build and install Lua in one step, do "<KBD>make all install</KBD>",
160 or "<KBD>make xxx install</KBD>",
161 where xxx is your platform name.
162
163 <P>
164 To install Lua locally after building it, do "<KBD>make local</KBD>".
165 This will create a directory <TT>install</TT> with subdirectories
166 <TT>bin</TT>, <TT>include</TT>, <TT>lib</TT>, <TT>man</TT>, <TT>share</TT>,
167 and install Lua as listed below.
168
169 To install Lua locally, but in some other directory, do
170 "<KBD>make install INSTALL_TOP=xxx</KBD>", where xxx is your chosen directory.
171 The installation starts in the <TT>src</TT> and <TT>doc</TT> directories,
172 so take care if <TT>INSTALL_TOP</TT> is not an absolute path.
173
174 <DL CLASS="display">
175 <DT>
176 bin:
177 <DD>
178 lua luac
179 <DT>
180 include:
181 <DD>
182 lua.h luaconf.h lualib.h lauxlib.h lua.hpp
183 <DT>
184 lib:
185 <DD>
186 liblua.a
187 <DT>
188 man/man1:
189 <DD>
190 lua.1 luac.1
191 </DL>
192
193 <P>
194 These are the only directories you need for development.
195 If you only want to run Lua programs,
196 you only need the files in <TT>bin</TT> and <TT>man</TT>.
197 The files in <TT>include</TT> and <TT>lib</TT> are needed for
198 embedding Lua in C or C++ programs.
199
200 <H3><A NAME="customization">Customization</A></H3>
201 <P>
202 Three kinds of things can be customized by editing a file:
203 <UL>
204 <LI> Where and how to install Lua &mdash; edit <TT>Makefile</TT>.
205 <LI> How to build Lua &mdash; edit <TT>src/Makefile</TT>.
206 <LI> Lua features &mdash; edit <TT>src/luaconf.h</TT>.
207 </UL>
208
209 <P>
210 You don't actually need to edit the Makefiles because you may set the
211 relevant variables in the command line when invoking make.
212 Nevertheless, it's probably best to edit and save the Makefiles to
213 record the changes you've made.
214
215 <P>
216 On the other hand, if you need to customize some Lua features,
217 edit <TT>src/luaconf.h</TT> before building and installing Lua.
218 The edited file will be the one installed, and
219 it will be used by any Lua clients that you build, to ensure consistency.
220 Further customization is available to experts by editing the Lua sources.
221
222 <H3><A NAME="other">Building Lua on other systems</A></H3>
223 <P>
224 If you're not using the usual Unix tools, then the instructions for
225 building Lua depend on the compiler you use. You'll need to create
226 projects (or whatever your compiler uses) for building the library,
227 the interpreter, and the compiler, as follows:
228
229 <DL CLASS="display">
230 <DT>
231 library:
232 <DD>
233 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
234 lauxlib.c lbaselib.c lcorolib.c ldblib.c liolib.c lmathlib.c loadlib.c loslib.c lstrlib.c ltablib.c lutf8lib.c linit.c
235 <DT>
236 interpreter:
237 <DD>
238 library, lua.c
239 <DT>
240 compiler:
241 <DD>
242 library, luac.c
243 </DL>
244
245 <P>
246 To use Lua as a library in your own programs, you need to know how to
247 create and use libraries with your compiler. Moreover, to dynamically load
248 C libraries for Lua, you'll need to know how to create dynamic libraries
249 and you'll need to make sure that the Lua API functions are accessible to
250 those dynamic libraries &mdash; but <EM>don't</EM> link the Lua library
251 into each dynamic library. For Unix, we recommend that the Lua library
252 be linked statically into the host program and its symbols exported for
253 dynamic linking; <TT>src/Makefile</TT> does this for the Lua interpreter.
254 For Windows, we recommend that the Lua library be a DLL.
255 In all cases, the compiler luac should be linked statically.
256
257 <P>
258 As mentioned above, you may edit <TT>src/luaconf.h</TT> to customize
259 some features before building Lua.
260
261 <H2><A NAME="changes">Changes since Lua 5.3</A></H2>
262 <P>
263 Here are the main changes introduced in Lua 5.4.
264 The
265 <A HREF="contents.html">reference manual</A>
266 lists the
267 <A HREF="manual.html#8">incompatibilities</A> that had to be introduced.
268
269 <H3>Main changes</H3>
270 <UL>
271 <LI> new generational mode for garbage collection
272 <LI> to-be-closed variables
273 <LI> const variables
274 <LI> userdata can have multiple user values
275 <LI> new implementation for math.random
276 <LI> warning system
277 <LI> debug information about function arguments and returns
278 <LI> new semantics for the integer 'for' loop
279 <LI> optional 'init' argument to 'string.gmatch'
280 <LI> new functions 'lua_resetthread' and 'coroutine.close'
281 <LI> string-to-number coercions moved to the string library
282 <LI> allocation function allowed to fail when shrinking a memory block
283 <LI> new format '%p' in 'string.format'
284 <LI> utf8 library accepts codepoints up to 2^31
285 </UL>
286
287 <H2><A NAME="license">License</A></H2>
288 <P>
289 <A HREF="https://opensource.org/osd">
290 <IMG SRC="OSIApproved_100X125.png" ALIGN="right" ALT="[Open Source Initiative Approved License]" STYLE="padding-left: 1em" WIDTH=50>
291 </A>
292 Lua is free software distributed under the terms of the
293 <A HREF="https://opensource.org/license/mit">MIT license</A>
294 reproduced below;
295 it may be used for any purpose, including commercial purposes,
296 at absolutely no cost without having to ask us.
297
298 The only requirement is that if you do use Lua,
299 then you should give us credit by including the appropriate copyright notice somewhere in your product or its documentation.
300
301 For details, see the
302 <A HREF="https://www.lua.org/license.html">license page</A>.
303
304 <BLOCKQUOTE STYLE="padding-bottom: 0em">
305 Copyright &copy; 1994&ndash;2025 Lua.org, PUC-Rio.
306
307 <P>
308 Permission is hereby granted, free of charge, to any person obtaining a copy
309 of this software and associated documentation files (the "Software"), to deal
310 in the Software without restriction, including without limitation the rights
311 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
312 copies of the Software, and to permit persons to whom the Software is
313 furnished to do so, subject to the following conditions:
314
315 <P>
316 The above copyright notice and this permission notice shall be included in
317 all copies or substantial portions of the Software.
318
319 <P>
320 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
321 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
322 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
323 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
324 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
325 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
326 THE SOFTWARE.
327 </BLOCKQUOTE>
328 <P>
329
330 <P CLASS="footer">
331 Last update:
332 Wed May 21 21:12:01 UTC 2025
333 </P>
334 <!--
335 Last change: revised for Lua 5.4.8
336 -->
337
338 </BODY>
339 </HTML>