summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-01-29 15:08:23 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-01-29 15:08:23 -0200
commit84df3ac2675af018d85d26746165325475575965 (patch)
tree7b00aeddd7382269cc5fc33c19818c01ef276e22
parent55a70c9719cce1b5b9ba78919a0ab54c8442af73 (diff)
downloadlua-84df3ac2675af018d85d26746165325475575965.tar.gz
lua-84df3ac2675af018d85d26746165325475575965.tar.bz2
lua-84df3ac2675af018d85d26746165325475575965.zip
new functions "tostring", "assert", and "format".
-rw-r--r--manual.tex57
1 files changed, 50 insertions, 7 deletions
diff --git a/manual.tex b/manual.tex
index 584808e6..3420e87e 100644
--- a/manual.tex
+++ b/manual.tex
@@ -1,3 +1,5 @@
1% $Id: $
2
1\documentstyle[A4,11pt,bnf]{article} 3\documentstyle[A4,11pt,bnf]{article}
2 4
3\newcommand{\rw}[1]{{\bf #1}} 5\newcommand{\rw}[1]{{\bf #1}}
@@ -42,6 +44,8 @@ as a configuration language for any program that needs one.
42This document describes version 2.2 of the Lua programming language and the 44This document describes version 2.2 of the Lua programming language and the
43API that allows interaction between Lua programs and its host C program. 45API that allows interaction between Lua programs and its host C program.
44It also presents some examples of using the main features of the system. 46It also presents some examples of using the main features of the system.
47
48{\em Lua manual: \verb$Date$, \verb$Revision$}
45\end{abstract} 49\end{abstract}
46 50
47\vspace{4ex} 51\vspace{4ex}
@@ -1080,8 +1084,9 @@ it can be unlocked with a call to \verb'lua_unlock'.
1080The set of \Index{predefined functions} in Lua is small but powerful. 1084The set of \Index{predefined functions} in Lua is small but powerful.
1081Most of them provide features that allows some degree of 1085Most of them provide features that allows some degree of
1082\Index{reflexivity} in the language. 1086\Index{reflexivity} in the language.
1083Many of these features cannot be simulated with the rest of the 1087Some of these features cannot be simulated with the rest of the
1084Language nor with the standard API. 1088Language nor with the standard Lua API.
1089Others are just helpful interfaces to common API functions.
1085 1090
1086The libraries, on the other hand, provide useful routines 1091The libraries, on the other hand, provide useful routines
1087that are implemented directly through the standard API. 1092that are implemented directly through the standard API.
@@ -1104,7 +1109,10 @@ declared in \verb-lualib.h-.
1104\subsubsection*{{\tt dofile (filename)}}\Deffunc{dofile} 1109\subsubsection*{{\tt dofile (filename)}}\Deffunc{dofile}
1105This function receives a file name, 1110This function receives a file name,
1106opens it and executes its contents as a Lua chunk. 1111opens it and executes its contents as a Lua chunk.
1112When called without arguments,
1113it executes the contents of the standard input.
1107It returns 1 if there are no errors, \nil\ otherwise. 1114It returns 1 if there are no errors, \nil\ otherwise.
1115It issues an error when called with a non string argument.
1108 1116
1109\subsubsection*{{\tt dostring (string)}}\Deffunc{dostring} 1117\subsubsection*{{\tt dostring (string)}}\Deffunc{dostring}
1110This function executes a given string as a Lua chunk. 1118This function executes a given string as a Lua chunk.
@@ -1141,6 +1149,10 @@ and its value,
1141or \nil\ if there are no more variables. 1149or \nil\ if there are no more variables.
1142See Section \ref{exnext} for an example of the use of this function. 1150See Section \ref{exnext} for an example of the use of this function.
1143 1151
1152\subsubsection*{{\tt tostring (e)}}\Deffunc{tostring}
1153This function receives an argument of any type and
1154converts it to a string in a reasonable format.
1155
1144\subsubsection*{{\tt print (e1, e2, ...)}}\Deffunc{print} 1156\subsubsection*{{\tt print (e1, e2, ...)}}\Deffunc{print}
1145This function receives any number of arguments, 1157This function receives any number of arguments,
1146and prints their values in a reasonable format. 1158and prints their values in a reasonable format.
@@ -1174,6 +1186,10 @@ This tag can be used to distinguish between user
1174data with different tags, 1186data with different tags,
1175and between C functions and Lua functions. 1187and between C functions and Lua functions.
1176 1188
1189\subsubsection*{{\tt assert (v)}}\Deffunc{assert}
1190This function issues an {\em ``assertion failed!''} error
1191when its argument is \nil.
1192
1177\subsubsection*{{\tt error (message)}}\Deffunc{error} 1193\subsubsection*{{\tt error (message)}}\Deffunc{error}
1178This function issues an error message and terminates 1194This function issues an error message and terminates
1179the last called function from the library 1195the last called function from the library
@@ -1185,6 +1201,7 @@ This function assigns the given value to a global variable.
1185The string \verb'name' does not need to be a syntactically valid variable name. 1201The string \verb'name' does not need to be a syntactically valid variable name.
1186Therefore, this function can set global variables with strange names like 1202Therefore, this function can set global variables with strange names like
1187\verb'm v 1' or \verb'34'. 1203\verb'm v 1' or \verb'34'.
1204It returns the value of its second argument.
1188 1205
1189\subsubsection*{{\tt getglobal (name)}}\Deffunc{getglobal} 1206\subsubsection*{{\tt getglobal (name)}}\Deffunc{getglobal}
1190This function retrieves the value of a global variable. 1207This function retrieves the value of a global variable.
@@ -1240,11 +1257,19 @@ All other characters are left unchanged.
1240Returns the ascii code of the character \verb's[i]'. 1257Returns the ascii code of the character \verb's[i]'.
1241If \verb'i' is absent, it is assumed to be 1. 1258If \verb'i' is absent, it is assumed to be 1.
1242 1259
1243\subsubsection*{{\tt int2str (\{i\})}}\Deffunc{int2str} 1260\subsubsection*{{\tt format (formatstring, e1, e2, \ldots)}}\Deffunc{format}
1244Receives 0 or more numbers. 1261This function returns a formated version of its variable number of arguments
1245Returns a string with length equal to the number of arguments, 1262following the description given in its first argument (which must be a string).
1246wherein each character has ascii value equal 1263The format string follows the same rules as the \verb'printf' family of
1247to its correspondent argument. 1264standard C functions.
1265The only differencies are that the options/modifiers
1266 \verb'*', \verb'l', \verb'L', \verb'n', \verb'p',
1267 and \verb'h' are not supported.
1268The options \verb'c', \verb'd', \verb'i', \verb'o', \verb'u',
1269\verb'x', \verb'X', \verb'e', \verb'E', \verb'f', and \verb'g' all
1270expect a number argument,
1271while \verb's' expects a string.
1272
1248 1273
1249\subsection{Mathematical Functions} \label{mathlib} 1274\subsection{Mathematical Functions} \label{mathlib}
1250 1275
@@ -1350,6 +1375,8 @@ Particularly, the format \verb'"s1"' reads a single character.
1350\subsubsection*{{\tt readuntil (char)}}\Deffunc{readuntil} 1375\subsubsection*{{\tt readuntil (char)}}\Deffunc{readuntil}
1351 1376
1352Reads the current input until the first ocurrence of the given character. 1377Reads the current input until the first ocurrence of the given character.
1378When called with no parameters or with nil,
1379reads until the end of the current input file.
1353Returns the string read. 1380Returns the string read.
1354The character itself is not read. 1381The character itself is not read.
1355 1382
@@ -1383,10 +1410,26 @@ For integers, it is the minimum number of digits.
1383This option has no meaning for strings. 1410This option has no meaning for strings.
1384\end{description} 1411\end{description}
1385 1412
1413{\em Warning:}
1414This format parameter is now obsolete;
1415formated output should use the \verb'format' function.
1416
1386When called without a format string, 1417When called without a format string,
1387this function writes numbers using the \verb'%g' format 1418this function writes numbers using the \verb'%g' format
1388and strings with \verb'%s'. 1419and strings with \verb'%s'.
1389 1420
1421\subsubsection*{{\tt date ()}}\Deffunc{date}
1422
1423This function returns 4 values:
1424the current day of the month,
1425the month ([1-12]), the current year,
1426and the day of the week (1 = Sunday, 7 = Saturday).
1427
1428\subsubsection*{{\tt time ()}}\Deffunc{time}
1429
1430This function returns the current time through 3 values:
1431hours ([0-23]), minutes, and seconds.
1432
1390% \subsubsection*{{\tt debug ()}} 1433% \subsubsection*{{\tt debug ()}}
1391% This function, when called, repeatedly presents a prompt \verb'lua_debug> ' 1434% This function, when called, repeatedly presents a prompt \verb'lua_debug> '
1392% in the error output stream (\verb'stderr'), 1435% in the error output stream (\verb'stderr'),