xref: /netbsd-src/external/mit/lua/dist/doc/readme.html (revision bdda0531de537df87feb2bf576711ab1be9b3675)
14ab4902eSlneto<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2dbec5304Smbalmer<HTML>
3dbec5304Smbalmer<HEAD>
4f0dad708Snikita<TITLE>Lua 5.4 readme</TITLE>
5dbec5304Smbalmer<LINK REL="stylesheet" TYPE="text/css" HREF="lua.css">
64ab4902eSlneto<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=iso-8859-1">
74ab4902eSlneto<STYLE TYPE="text/css">
84ab4902eSlnetoblockquote, .display {
94ab4902eSlneto	border: solid #a0a0a0 2px ;
10f03f2e0fSmbalmer	border-radius: 8px ;
114ab4902eSlneto	padding: 1em ;
124ab4902eSlneto	margin: 0px ;
134ab4902eSlneto}
144ab4902eSlneto
154ab4902eSlneto.display {
164ab4902eSlneto	word-spacing: 0.25em ;
174ab4902eSlneto}
184ab4902eSlneto
194ab4902eSlnetodl.display dd {
204ab4902eSlneto	padding-bottom: 0.2em ;
214ab4902eSlneto}
224ab4902eSlneto
234ab4902eSlnetott, kbd, code {
244ab4902eSlneto	font-size: 12pt ;
254ab4902eSlneto}
264ab4902eSlneto</STYLE>
27dbec5304Smbalmer</HEAD>
28dbec5304Smbalmer
29dbec5304Smbalmer<BODY>
30dbec5304Smbalmer
31dbec5304Smbalmer<H1>
32f03f2e0fSmbalmer<A HREF="http://www.lua.org/"><IMG SRC="logo.gif" ALT="Lua"></A>
33f0dad708SnikitaWelcome to Lua 5.4
34dbec5304Smbalmer</H1>
35dbec5304Smbalmer
36f03f2e0fSmbalmer<DIV CLASS="menubar">
374ab4902eSlneto<A HREF="#about">about</A>
384ab4902eSlneto&middot;
394ab4902eSlneto<A HREF="#install">installation</A>
404ab4902eSlneto&middot;
414ab4902eSlneto<A HREF="#changes">changes</A>
424ab4902eSlneto&middot;
434ab4902eSlneto<A HREF="#license">license</A>
444ab4902eSlneto&middot;
454ab4902eSlneto<A HREF="contents.html">reference manual</A>
46f03f2e0fSmbalmer</DIV>
47dbec5304Smbalmer
484ab4902eSlneto<H2><A NAME="about">About Lua</A></H2>
494ab4902eSlneto<P>
50f0dad708SnikitaLua is a powerful, efficient, lightweight, embeddable scripting language
514ab4902eSlnetodeveloped by a
524ab4902eSlneto<A HREF="http://www.lua.org/authors.html">team</A>
534ab4902eSlnetoat
544ab4902eSlneto<A HREF="http://www.puc-rio.br/">PUC-Rio</A>,
554ab4902eSlnetothe Pontifical Catholic University of Rio de Janeiro in Brazil.
564ab4902eSlnetoLua is
574ab4902eSlneto<A HREF="#license">free software</A>
58f0dad708Snikitaused in
59f0dad708Snikita<A HREF="http://www.lua.org/uses.html">many products and projects</A>
60f0dad708Snikitaaround the world.
614ab4902eSlneto
624ab4902eSlneto<P>
63dbec5304SmbalmerLua's
64dbec5304Smbalmer<A HREF="http://www.lua.org/">official web site</A>
654ab4902eSlnetoprovides complete information
664ab4902eSlnetoabout Lua,
674ab4902eSlnetoincluding
684ab4902eSlnetoan
694ab4902eSlneto<A HREF="http://www.lua.org/about.html">executive summary</A>
704ab4902eSlnetoand
714ab4902eSlnetoupdated
724ab4902eSlneto<A HREF="http://www.lua.org/docs.html">documentation</A>,
73dbec5304Smbalmerespecially the
74f0dad708Snikita<A HREF="http://www.lua.org/manual/5.4/">reference manual</A>,
754ab4902eSlnetowhich may differ slightly from the
764ab4902eSlneto<A HREF="contents.html">local copy</A>
774ab4902eSlnetodistributed in this package.
784ab4902eSlneto
794ab4902eSlneto<H2><A NAME="install">Installing Lua</A></H2>
804ab4902eSlneto<P>
814ab4902eSlnetoLua is distributed in
824ab4902eSlneto<A HREF="http://www.lua.org/ftp/">source</A>
834ab4902eSlnetoform.
844ab4902eSlnetoYou need to build it before using it.
854ab4902eSlnetoBuilding Lua should be straightforward
864ab4902eSlnetobecause
874ab4902eSlnetoLua is implemented in pure ANSI C and compiles unmodified in all known
884ab4902eSlnetoplatforms that have an ANSI C compiler.
894ab4902eSlnetoLua also compiles unmodified as C++.
90f0dad708SnikitaThe instructions given below for building Lua are for Unix-like platforms,
91f0dad708Snikitasuch as Linux and Mac OS X.
924ab4902eSlnetoSee also
934ab4902eSlneto<A HREF="#other">instructions for other systems</A>
944ab4902eSlnetoand
954ab4902eSlneto<A HREF="#customization">customization options</A>.
964ab4902eSlneto
974ab4902eSlneto<P>
984ab4902eSlnetoIf you don't have the time or the inclination to compile Lua yourself,
994ab4902eSlnetoget a binary from
1004ab4902eSlneto<A HREF="http://lua-users.org/wiki/LuaBinaries">LuaBinaries</A>.
1014ab4902eSlneto
1024ab4902eSlneto<H3>Building Lua</H3>
1034ab4902eSlneto<P>
104f0dad708SnikitaIn most common Unix-like platforms, simply do "<KBD>make</KBD>".
1054ab4902eSlnetoHere are the details.
1064ab4902eSlneto
1074ab4902eSlneto<OL>
1084ab4902eSlneto<LI>
1094ab4902eSlnetoOpen a terminal window and move to
110*bdda0531Snikitathe top-level directory, which is named <TT>lua-5.4.6</TT>.
1114ab4902eSlnetoThe <TT>Makefile</TT> there controls both the build process and the installation process.
1124ab4902eSlneto<P>
1134ab4902eSlneto<LI>
114f0dad708Snikita  Do "<KBD>make</KBD>". The <TT>Makefile</TT> will guess your platform and build Lua for it.
115f0dad708Snikita<P>
116f0dad708Snikita<LI>
117f0dad708Snikita  If the guess failed, do "<KBD>make help</KBD>" and see if your platform is listed.
1184ab4902eSlneto  The platforms currently supported are:
1194ab4902eSlneto<P>
1204ab4902eSlneto<P CLASS="display">
121*bdda0531Snikita   guess aix bsd c89 freebsd generic ios linux linux-readline macosx mingw posix solaris
1224ab4902eSlneto</P>
1234ab4902eSlneto<P>
1244ab4902eSlneto  If your platform is listed, just do "<KBD>make xxx</KBD>", where xxx
1254ab4902eSlneto  is your platform name.
1264ab4902eSlneto<P>
1274ab4902eSlneto  If your platform is not listed, try the closest one or posix, generic,
12873008250Slneto  c89, in this order.
1294ab4902eSlneto<P>
1304ab4902eSlneto<LI>
1314ab4902eSlnetoThe compilation takes only a few moments
1324ab4902eSlnetoand produces three files in the <TT>src</TT> directory:
1334ab4902eSlnetolua (the interpreter),
1344ab4902eSlnetoluac (the compiler),
1354ab4902eSlnetoand liblua.a (the library).
1364ab4902eSlneto<P>
1374ab4902eSlneto<LI>
1384ab4902eSlneto  To check that Lua has been built correctly, do "<KBD>make test</KBD>"
1394ab4902eSlneto  after building Lua. This will run the interpreter and print its version.
1404ab4902eSlneto</OL>
1414ab4902eSlneto<P>
142f0dad708SnikitaIf you're running Linux, try "<KBD>make linux-readline</KBD>" to build the interactive Lua interpreter with handy line-editing and history capabilities.
143f0dad708SnikitaIf you get compilation errors,
144f03f2e0fSmbalmermake sure you have installed the <TT>readline</TT> development package
145f03f2e0fSmbalmer(which is probably named <TT>libreadline-dev</TT> or <TT>readline-devel</TT>).
1464ab4902eSlnetoIf you get link errors after that,
147f0dad708Snikitathen try "<KBD>make linux-readline MYLIBS=-ltermcap</KBD>".
1484ab4902eSlneto
1494ab4902eSlneto<H3>Installing Lua</H3>
1504ab4902eSlneto<P>
1514ab4902eSlneto  Once you have built Lua, you may want to install it in an official
1524ab4902eSlneto  place in your system. In this case, do "<KBD>make install</KBD>". The official
1534ab4902eSlneto  place and the way to install files are defined in the <TT>Makefile</TT>. You'll
154f0dad708Snikita  probably need the right permissions to install files, and so may need to do "<KBD>sudo make install</KBD>".
1554ab4902eSlneto
1564ab4902eSlneto<P>
157f0dad708Snikita  To build and install Lua in one step, do "<KBD>make all install</KBD>",
158f0dad708Snikita  or "<KBD>make xxx install</KBD>",
1594ab4902eSlneto  where xxx is your platform name.
1604ab4902eSlneto
1614ab4902eSlneto<P>
162f0dad708Snikita  To install Lua locally after building it, do "<KBD>make local</KBD>".
1634ab4902eSlneto  This will create a directory <TT>install</TT> with subdirectories
1644ab4902eSlneto  <TT>bin</TT>, <TT>include</TT>, <TT>lib</TT>, <TT>man</TT>, <TT>share</TT>,
1654ab4902eSlneto  and install Lua as listed below.
1664ab4902eSlneto
1674ab4902eSlneto  To install Lua locally, but in some other directory, do
1684ab4902eSlneto  "<KBD>make install INSTALL_TOP=xxx</KBD>", where xxx is your chosen directory.
1694ab4902eSlneto  The installation starts in the <TT>src</TT> and <TT>doc</TT> directories,
1704ab4902eSlneto  so take care if <TT>INSTALL_TOP</TT> is not an absolute path.
1714ab4902eSlneto
1724ab4902eSlneto<DL CLASS="display">
1734ab4902eSlneto<DT>
1744ab4902eSlneto    bin:
1754ab4902eSlneto<DD>
1764ab4902eSlneto    lua luac
1774ab4902eSlneto<DT>
1784ab4902eSlneto    include:
1794ab4902eSlneto<DD>
180f03f2e0fSmbalmer    lua.h luaconf.h lualib.h lauxlib.h lua.hpp
1814ab4902eSlneto<DT>
1824ab4902eSlneto    lib:
1834ab4902eSlneto<DD>
1844ab4902eSlneto    liblua.a
1854ab4902eSlneto<DT>
1864ab4902eSlneto    man/man1:
1874ab4902eSlneto<DD>
1884ab4902eSlneto    lua.1 luac.1
1894ab4902eSlneto</DL>
1904ab4902eSlneto
1914ab4902eSlneto<P>
1924ab4902eSlneto  These are the only directories you need for development.
1934ab4902eSlneto  If you only want to run Lua programs,
1944ab4902eSlneto  you only need the files in <TT>bin</TT> and <TT>man</TT>.
1954ab4902eSlneto  The files in <TT>include</TT> and <TT>lib</TT> are needed for
1964ab4902eSlneto  embedding Lua in C or C++ programs.
1974ab4902eSlneto
1984ab4902eSlneto<H3><A NAME="customization">Customization</A></H3>
1994ab4902eSlneto<P>
2004ab4902eSlneto  Three kinds of things can be customized by editing a file:
2014ab4902eSlneto<UL>
2024ab4902eSlneto    <LI> Where and how to install Lua &mdash; edit <TT>Makefile</TT>.
2034ab4902eSlneto    <LI> How to build Lua &mdash; edit <TT>src/Makefile</TT>.
2044ab4902eSlneto    <LI> Lua features &mdash; edit <TT>src/luaconf.h</TT>.
2054ab4902eSlneto</UL>
2064ab4902eSlneto
2074ab4902eSlneto<P>
2084ab4902eSlneto  You don't actually need to edit the Makefiles because you may set the
2094ab4902eSlneto  relevant variables in the command line when invoking make.
2104ab4902eSlneto  Nevertheless, it's probably best to edit and save the Makefiles to
2114ab4902eSlneto  record the changes you've made.
2124ab4902eSlneto
2134ab4902eSlneto<P>
2144ab4902eSlneto  On the other hand, if you need to customize some Lua features, you'll need
2154ab4902eSlneto  to edit <TT>src/luaconf.h</TT> before building and installing Lua.
2164ab4902eSlneto  The edited file will be the one installed, and
2174ab4902eSlneto  it will be used by any Lua clients that you build, to ensure consistency.
2184ab4902eSlneto  Further customization is available to experts by editing the Lua sources.
2194ab4902eSlneto
2204ab4902eSlneto<H3><A NAME="other">Building Lua on other systems</A></H3>
2214ab4902eSlneto<P>
2224ab4902eSlneto  If you're not using the usual Unix tools, then the instructions for
2234ab4902eSlneto  building Lua depend on the compiler you use. You'll need to create
2244ab4902eSlneto  projects (or whatever your compiler uses) for building the library,
2254ab4902eSlneto  the interpreter, and the compiler, as follows:
2264ab4902eSlneto
2274ab4902eSlneto<DL CLASS="display">
2284ab4902eSlneto<DT>
2294ab4902eSlnetolibrary:
2304ab4902eSlneto<DD>
231f0dad708Snikitalapi.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
232f0dad708Snikitalauxlib.c lbaselib.c lcorolib.c ldblib.c liolib.c lmathlib.c loadlib.c loslib.c lstrlib.c ltablib.c lutf8lib.c linit.c
2334ab4902eSlneto<DT>
2344ab4902eSlnetointerpreter:
2354ab4902eSlneto<DD>
2364ab4902eSlneto  library, lua.c
2374ab4902eSlneto<DT>
2384ab4902eSlnetocompiler:
2394ab4902eSlneto<DD>
2404ab4902eSlneto  library, luac.c
2414ab4902eSlneto</DL>
2424ab4902eSlneto
2434ab4902eSlneto<P>
244f0dad708Snikita  To use Lua as a library in your own programs, you'll need to know how to
2454ab4902eSlneto  create and use libraries with your compiler. Moreover, to dynamically load
246f0dad708Snikita  C libraries for Lua, you'll need to know how to create dynamic libraries
2474ab4902eSlneto  and you'll need to make sure that the Lua API functions are accessible to
2484ab4902eSlneto  those dynamic libraries &mdash; but <EM>don't</EM> link the Lua library
2494ab4902eSlneto  into each dynamic library. For Unix, we recommend that the Lua library
2504ab4902eSlneto  be linked statically into the host program and its symbols exported for
2514ab4902eSlneto  dynamic linking; <TT>src/Makefile</TT> does this for the Lua interpreter.
2524ab4902eSlneto  For Windows, we recommend that the Lua library be a DLL.
25373008250Slneto  In all cases, the compiler luac should be linked statically.
2544ab4902eSlneto
2554ab4902eSlneto<P>
2564ab4902eSlneto  As mentioned above, you may edit <TT>src/luaconf.h</TT> to customize
2574ab4902eSlneto  some features before building Lua.
2584ab4902eSlneto
259f0dad708Snikita<H2><A NAME="changes">Changes since Lua 5.3</A></H2>
2604ab4902eSlneto<P>
261f0dad708SnikitaHere are the main changes introduced in Lua 5.4.
2624ab4902eSlnetoThe
2634ab4902eSlneto<A HREF="contents.html">reference manual</A>
2644ab4902eSlnetolists the
2654ab4902eSlneto<A HREF="manual.html#8">incompatibilities</A> that had to be introduced.
2664ab4902eSlneto
2674ab4902eSlneto<H3>Main changes</H3>
2684ab4902eSlneto<UL>
269f0dad708Snikita<LI> new generational mode for garbage collection
270f0dad708Snikita<LI> to-be-closed variables
271f0dad708Snikita<LI> const variables
272f0dad708Snikita<LI> userdata can have multiple user values
273f0dad708Snikita<LI> new implementation for math.random
274f0dad708Snikita<LI> warning system
275f0dad708Snikita<LI> debug information about function arguments and returns
276f0dad708Snikita<LI> new semantics for the integer 'for' loop
277f0dad708Snikita<LI> optional 'init' argument to 'string.gmatch'
278f0dad708Snikita<LI> new functions 'lua_resetthread' and 'coroutine.close'
279f0dad708Snikita<LI> string-to-number coercions moved to the string library
280f0dad708Snikita<LI> allocation function allowed to fail when shrinking a memory block
281f0dad708Snikita<LI> new format '%p' in 'string.format'
282f0dad708Snikita<LI> utf8 library accepts codepoints up to 2^31
2834ab4902eSlneto</UL>
2844ab4902eSlneto
2854ab4902eSlneto<H2><A NAME="license">License</A></H2>
2864ab4902eSlneto<P>
287f03f2e0fSmbalmer<A HREF="http://www.opensource.org/docs/definition.php">
288f03f2e0fSmbalmer<IMG SRC="osi-certified-72x60.png" ALIGN="right" ALT="[osi certified]" STYLE="padding-left: 30px ;">
289f03f2e0fSmbalmer</A>
2904ab4902eSlnetoLua is free software distributed under the terms of the
2914ab4902eSlneto<A HREF="http://www.opensource.org/licenses/mit-license.html">MIT license</A>
2924ab4902eSlnetoreproduced below;
2934ab4902eSlnetoit may be used for any purpose, including commercial purposes,
2944ab4902eSlnetoat absolutely no cost without having to ask us.
2954ab4902eSlneto
2964ab4902eSlnetoThe only requirement is that if you do use Lua,
2974ab4902eSlnetothen you should give us credit by including the appropriate copyright notice somewhere in your product or its documentation.
2984ab4902eSlneto
2994ab4902eSlnetoFor details, see
3004ab4902eSlneto<A HREF="http://www.lua.org/license.html">this</A>.
3014ab4902eSlneto
3024ab4902eSlneto<BLOCKQUOTE STYLE="padding-bottom: 0em">
303*bdda0531SnikitaCopyright &copy; 1994&ndash;2023 Lua.org, PUC-Rio.
3044ab4902eSlneto
3054ab4902eSlneto<P>
3064ab4902eSlnetoPermission is hereby granted, free of charge, to any person obtaining a copy
3074ab4902eSlnetoof this software and associated documentation files (the "Software"), to deal
3084ab4902eSlnetoin the Software without restriction, including without limitation the rights
3094ab4902eSlnetoto use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3104ab4902eSlnetocopies of the Software, and to permit persons to whom the Software is
3114ab4902eSlnetofurnished to do so, subject to the following conditions:
3124ab4902eSlneto
3134ab4902eSlneto<P>
3144ab4902eSlnetoThe above copyright notice and this permission notice shall be included in
3154ab4902eSlnetoall copies or substantial portions of the Software.
3164ab4902eSlneto
3174ab4902eSlneto<P>
3184ab4902eSlnetoTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3194ab4902eSlnetoIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3204ab4902eSlnetoFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
3214ab4902eSlnetoAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3224ab4902eSlnetoLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3234ab4902eSlnetoOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3244ab4902eSlnetoTHE SOFTWARE.
3254ab4902eSlneto</BLOCKQUOTE>
326dbec5304Smbalmer<P>
327dbec5304Smbalmer
328f03f2e0fSmbalmer<P CLASS="footer">
329dbec5304SmbalmerLast update:
330*bdda0531SnikitaTue May  2 20:08:55 UTC 2023
331f03f2e0fSmbalmer</P>
3324ab4902eSlneto<!--
333*bdda0531SnikitaLast change: revised for Lua 5.4.6
3344ab4902eSlneto-->
335dbec5304Smbalmer
336dbec5304Smbalmer</BODY>
337dbec5304Smbalmer</HTML>
338