aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-03-14 14:45:01 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-03-14 14:45:01 -0300
commitf86c1367db7fb0559f80ef2025e62e71d8986d86 (patch)
tree360bdef49afa32f7c0d9070b7ce490bca8eb9af0
parent58fd8aa851eac8736815663c3116e2e45b533bad (diff)
downloadlua-f86c1367db7fb0559f80ef2025e62e71d8986d86.tar.gz
lua-f86c1367db7fb0559f80ef2025e62e71d8986d86.tar.bz2
lua-f86c1367db7fb0559f80ef2025e62e71d8986d86.zip
new functions "rename" and "tmpname".
new option 'q' for function "format". new example, about vararg.
-rw-r--r--manual.tex54
1 files changed, 46 insertions, 8 deletions
diff --git a/manual.tex b/manual.tex
index d4ce9ecf..a4a9c7c3 100644
--- a/manual.tex
+++ b/manual.tex
@@ -1,4 +1,4 @@
1% $Id: manual.tex,v 1.10 1996/02/12 18:32:09 roberto Exp roberto $ 1% $Id: manual.tex,v 1.11 1996/02/16 13:12:12 roberto Exp roberto $
2 2
3\documentstyle[A4,11pt,bnf]{article} 3\documentstyle[A4,11pt,bnf]{article}
4 4
@@ -34,7 +34,7 @@ Waldemar Celes Filho
34\tecgraf\ --- Departamento de Inform\'atica --- PUC-Rio 34\tecgraf\ --- Departamento de Inform\'atica --- PUC-Rio
35} 35}
36 36
37\date{\small \verb$Date: 1996/02/12 18:32:09 $} 37\date{\small \verb$Date: 1996/02/16 13:12:12 $}
38 38
39\maketitle 39\maketitle
40 40
@@ -1269,12 +1269,19 @@ following the description given in its first argument (which must be a string).
1269The format string follows the same rules as the \verb'printf' family of 1269The format string follows the same rules as the \verb'printf' family of
1270standard C functions. 1270standard C functions.
1271The only differencies are that the options/modifiers 1271The only differencies are that the options/modifiers
1272 \verb'*', \verb'l', \verb'L', \verb'n', \verb'p', 1272\verb'*', \verb'l', \verb'L', \verb'n', \verb'p',
1273 and \verb'h' are not supported. 1273and \verb'h' are not supported,
1274The options \verb'c', \verb'd', \verb'i', \verb'o', \verb'u', 1274and there is an extra option, \verb'q'.
1275\verb'x', \verb'X', \verb'e', \verb'E', \verb'f', and \verb'g' all 1275This option formats a string in a form suitable to be safely read
1276back by the Lua interpreter.
1277The string is written between double quotes,
1278and all double quotes, returns and backslashes in the string
1279are correctly escaped when written.
1280
1281The options \verb'c', \verb'd', \verb'E', \verb'e', \verb'f',
1282\verb'g' \verb'i', \verb'o', \verb'u', \verb'X', and \verb'x' all
1276expect a number argument, 1283expect a number argument,
1277while \verb's' expects a string. 1284while \verb'q' and \verb's' expects a string.
1278 1285
1279 1286
1280\subsection{Mathematical Functions} \label{mathlib} 1287\subsection{Mathematical Functions} \label{mathlib}
@@ -1360,6 +1367,15 @@ This function returns 2 if the file already exists,
1360 1367
1361This function deletes the file with the given name. 1368This function deletes the file with the given name.
1362 1369
1370\subsubsection*{{\tt rename (name1, name2)}}\Deffunc{rename}
1371
1372This function renames file \verb'name1' to \verb'name2'.
1373
1374\subsubsection*{{\tt tmpname ()}}\Deffunc{tmpname}
1375
1376This function returns a string with a file name that can safely
1377be used for a temporary file.
1378
1363\subsubsection*{{\tt read ([format])}}\Deffunc{read} 1379\subsubsection*{{\tt read ([format])}}\Deffunc{read}
1364 1380
1365This function returns a value read from the current input. 1381This function returns a value read from the current input.
@@ -1698,6 +1714,28 @@ end
1698\end{verbatim} 1714\end{verbatim}
1699 1715
1700 1716
1717\subsection{\Index{Variable number of arguments}}
1718Lua does not provide any explicit mechanism to deal with
1719variable number of arguments.
1720However, one can use table constructors to simulate this mechanism.
1721As an example, suppose a function to concatenate all its arguments.
1722It could be written like
1723\begin{verbatim}
1724function concat (o)
1725 local i = 1
1726 local s = ''
1727 while o[i] do
1728 s = s .. o[i]
1729 i = i+1
1730 end
1731 return s
1732end
1733\end{verbatim}
1734To call it, one uses a table constructor to join all arguments:
1735\begin{verbatim}
1736 x = concat{"hello ", "john", " and ", "mary"}
1737\end{verbatim}
1738
1701\subsection{\Index{Persistence}} 1739\subsection{\Index{Persistence}}
1702Because of its reflexive facilities, 1740Because of its reflexive facilities,
1703persistence in Lua can be achieved within the language. 1741persistence in Lua can be achieved within the language.
@@ -1829,7 +1867,7 @@ void Index (void)
1829\end{figure} 1867\end{figure}
1830This code must be registered with: 1868This code must be registered with:
1831\begin{verbatim} 1869\begin{verbatim}
1832 lua_pushliteral("parent"); 1870 lua_pushstring("parent");
1833 lockedParentName = lua_lock(); 1871 lockedParentName = lua_lock();
1834 lua_pushobject(lua_setfallback("index", Index)); 1872 lua_pushobject(lua_setfallback("index", Index));
1835 lockedOldIndex = lua_lock(); 1873 lockedOldIndex = lua_lock();