aboutsummaryrefslogtreecommitdiff
path: root/manual.tex
diff options
context:
space:
mode:
Diffstat (limited to 'manual.tex')
-rw-r--r--manual.tex99
1 files changed, 47 insertions, 52 deletions
diff --git a/manual.tex b/manual.tex
index 50d4e67e..5f56593c 100644
--- a/manual.tex
+++ b/manual.tex
@@ -1,8 +1,10 @@
1% $Id: manual.tex,v 1.16 1998/06/19 18:47:06 roberto Exp roberto $ 1% $Id: manual.tex,v 1.17 1998/06/29 18:09:28 roberto Exp roberto $
2 2
3\documentclass[11pt]{article} 3\documentclass[11pt]{article}
4\usepackage{fullpage,bnf} 4\usepackage{fullpage,bnf}
5 5
6\catcode`\_=12
7
6\newcommand{\See}[1]{Section~\ref{#1}} 8\newcommand{\See}[1]{Section~\ref{#1}}
7\newcommand{\see}[1]{(see \See{#1})} 9\newcommand{\see}[1]{(see \See{#1})}
8\newcommand{\M}[1]{\emph{#1}} 10\newcommand{\M}[1]{\emph{#1}}
@@ -19,7 +21,7 @@
19 21
20\newcommand{\ff}{$\bullet$\ } 22\newcommand{\ff}{$\bullet$\ }
21 23
22\newcommand{\Version}{3.1} 24\newcommand{\Version}{3.2 (alpha)}
23 25
24\makeindex 26\makeindex
25 27
@@ -39,7 +41,7 @@ Waldemar Celes
39\tecgraf\ --- Computer Science Department --- PUC-Rio 41\tecgraf\ --- Computer Science Department --- PUC-Rio
40} 42}
41 43
42%\date{\small \verb$Date: 1998/06/19 18:47:06 $} 44%\date{\small \verb$Date: 1998/06/29 18:09:28 $}
43 45
44\maketitle 46\maketitle
45 47
@@ -810,7 +812,7 @@ If the function is called in a place that can hold many values
810(syntactically denoted by the non-terminal \M{exp}), 812(syntactically denoted by the non-terminal \M{exp}),
811then no adjustment is made. 813then no adjustment is made.
812Note that the only place that can hold many values 814Note that the only place that can hold many values
813is the last expression (or the only one) in an assignment 815is the last (or the only) expression in an assignment
814or in a return statement; see examples below. 816or in a return statement; see examples below.
815\begin{verbatim} 817\begin{verbatim}
816 f(); -- adjusted to 0 818 f(); -- adjusted to 0
@@ -1263,22 +1265,20 @@ Because Lua is an extension language,
1263all Lua actions start from C code in the host program 1265all Lua actions start from C code in the host program
1264calling a function from the Lua library. 1266calling a function from the Lua library.
1265Whenever an error occurs during Lua compilation or execution, 1267Whenever an error occurs during Lua compilation or execution,
1266the \Def{error method} is called, 1268function \verb|_ERRORMESSAGE| is called \Deffunc{_ERRORMESSAGE}
1269(provided it is different from \nil),
1267and then the corresponding function from the library 1270and then the corresponding function from the library
1268(\verb|lua_dofile|, \verb|lua_dostring|, 1271(\verb|lua_dofile|, \verb|lua_dostring|,
1269\verb|lua_dobuffer|, or \verb|lua_callfunction|) 1272\verb|lua_dobuffer|, or \verb|lua_callfunction|)
1270is terminated, returning an error condition. 1273is terminated, returning an error condition.
1271 1274
1272The only argument to the error method is a string 1275The only argument to \verb|_ERRORMESSAGE| is a string
1273describing the error. 1276describing the error.
1274The default method prints this message to \verb|stderr|. 1277The default definition for this function calls \verb|_ALERT|,
1275If needed, it is possible to change the error method with the 1278which prints the message to \verb|stderr| \see{alert}.
1276function \verb|seterrormethod|, 1279The standard I/O library redefines \verb|_ERRORMESSAGE|,
1277which gets the new error handler as its only parameter 1280and uses the debug facilities \see{debugI}
1278\see{pdf-seterrormethod}. 1281to print some extra information,
1279The standard I/O library uses this facility to redefine the error method,
1280using the debug facilities \see{debugI},
1281in order to print some extra information,
1282such as the call stack. 1282such as the call stack.
1283 1283
1284To provide more information about errors, 1284To provide more information about errors,
@@ -1347,11 +1347,11 @@ For that, you must set \verb|lua_state| back to \verb|NULL| before
1347calling \verb|lua_open|. 1347calling \verb|lua_open|.
1348An easy way to do that is defining an auxiliary function: 1348An easy way to do that is defining an auxiliary function:
1349\begin{verbatim} 1349\begin{verbatim}
1350lua_State *lua_newstate (void) { 1350 lua_State *lua_newstate (void) {
1351 lua_State *old = lua_setstate(NULL); 1351 lua_State *old = lua_setstate(NULL);
1352 lua_open(); 1352 lua_open();
1353 return lua_setstate(old); 1353 return lua_setstate(old);
1354} 1354 }
1355\end{verbatim} 1355\end{verbatim}
1356This function creates a new state without changing the current state 1356This function creates a new state without changing the current state
1357of the interpreter. 1357of the interpreter.
@@ -1373,14 +1373,14 @@ If \verb|lua_state| is already \verb|NULL|,
1373\verb|lua_close| has no effect. 1373\verb|lua_close| has no effect.
1374 1374
1375If you are using multiple states, 1375If you are using multiple states,
1376you may find useful the following function, 1376you may find useful to define the following function,
1377which releases a given state: 1377which releases a given state:
1378\begin{verbatim} 1378\begin{verbatim}
1379void lua_freestate (lua_State *st) { 1379 void lua_freestate (lua_State *st) {
1380 lua_State *old = lua_setstate(st); 1380 lua_State *old = lua_setstate(st);
1381 lua_close(); 1381 lua_close();
1382 if (old != st) lua_setstate(old); 1382 if (old != st) lua_setstate(old);
1383} 1383 }
1384\end{verbatim} 1384\end{verbatim}
1385 1385
1386\subsection{Exchanging Values between C and Lua} \label{valuesCLua} 1386\subsection{Exchanging Values between C and Lua} \label{valuesCLua}
@@ -1736,18 +1736,10 @@ If the C function has been called from Lua,
1736then the corresponding Lua execution terminates, 1736then the corresponding Lua execution terminates,
1737as if an error had occurred inside Lua code. 1737as if an error had occurred inside Lua code.
1738Otherwise, the whole program terminates with a call to \verb|exit(1)|. 1738Otherwise, the whole program terminates with a call to \verb|exit(1)|.
1739The \verb|message| is passed to the error handler method. 1739The \verb|message| is passed to the error handler function,
1740\verb|_ERRORMESSAGE|.
1740If \verb|message| is \verb|NULL|, 1741If \verb|message| is \verb|NULL|,
1741the error handler method is not called. 1742\verb|_ERRORMESSAGE| is not called.
1742
1743The error handler method \see{error} can be
1744changed with: \Deffunc{lua_seterrormethod}
1745\begin{verbatim}
1746lua_Object lua_seterrormethod (void);
1747\end{verbatim}
1748This function sets the object at the top of C2lua
1749as the new error method,
1750and returns the old error method value.
1751 1743
1752Tag methods can be changed with: \Deffunc{lua_settagmethod} 1744Tag methods can be changed with: \Deffunc{lua_settagmethod}
1753\begin{verbatim} 1745\begin{verbatim}
@@ -1885,7 +1877,7 @@ and \verb|lua_iolibopen|, declared in \verb|lualib.h|.
1885 1877
1886\subsection{Predefined Functions} \label{predefined} 1878\subsection{Predefined Functions} \label{predefined}
1887 1879
1888\subsubsection*{\ff \T{call (func, arg [, mode [, errmethod]])}}\Deffunc{call} 1880\subsubsection*{\ff \T{call (func, arg [, mode [, errhandler]])}}\Deffunc{call}
1889\label{pdf-call} 1881\label{pdf-call}
1890This function calls function \verb|func| with 1882This function calls function \verb|func| with
1891the arguments given by the table \verb|arg|. 1883the arguments given by the table \verb|arg|.
@@ -1917,14 +1909,15 @@ if an error occurs during the function call,
1917the error is propagated. 1909the error is propagated.
1918If the string \verb|mode| contains \verb|"x"|, 1910If the string \verb|mode| contains \verb|"x"|,
1919then the call is \emph{protected}.\index{protected calls} 1911then the call is \emph{protected}.\index{protected calls}
1920In this mode, function \verb|call| does not generate an error, 1912In this mode, function \verb|call| does not propagate an error,
1921whatever happens during the call. 1913whatever happens during the call.
1922Instead, it returns \nil\ to signal the error 1914Instead, it returns \nil\ to signal the error
1923(besides calling the appropriated error method). 1915(besides calling the appropriated error handler).
1924 1916
1925If provided, \verb|errmethod| is temporarily set as the error method, 1917If provided,
1926while \verb|func| runs. 1918\verb|errhandler| is temporarily set as the error function
1927As a particular case, if \verb|errmethod| is \nil, 1919\verb|_ERRORMESSAGE|, while \verb|func| runs.
1920As a particular example, if \verb|errhandler| is \nil,
1928no error messages will be issued during the execution of the called function. 1921no error messages will be issued during the execution of the called function.
1929 1922
1930\subsubsection*{\ff \T{collectgarbage ([limit])}}\Deffunc{collectgarbage} 1923\subsubsection*{\ff \T{collectgarbage ([limit])}}\Deffunc{collectgarbage}
@@ -2055,9 +2048,16 @@ This function receives any number of arguments,
2055and prints their values using the strings returned by \verb|tostring|. 2048and prints their values using the strings returned by \verb|tostring|.
2056This function is not intended for formatted output, 2049This function is not intended for formatted output,
2057but only as a quick way to show a value, 2050but only as a quick way to show a value,
2058for instance for error messages or debugging. 2051for instance for debugging.
2059See \See{libio} for functions for formatted output. 2052See \See{libio} for functions for formatted output.
2060 2053
2054\subsubsection*{\ff \T{_ALERT (message)}}\Deffunc{alert}\label{alert}
2055This function prints its only string argument to \IndexVerb{stderr}.
2056All error messages in Lua are printed through this function.
2057Therefore, a program may redefine it
2058to change the way such messages are shown
2059(for instance, for systems without \verb|stderr|).
2060
2061\subsubsection*{\ff \T{tonumber (e [, base])}}\Deffunc{tonumber} 2061\subsubsection*{\ff \T{tonumber (e [, base])}}\Deffunc{tonumber}
2062This function receives one argument, 2062This function receives one argument,
2063and tries to convert it to a number. 2063and tries to convert it to a number.
@@ -2164,13 +2164,6 @@ Its full semantics is explained in \See{tag-method}.
2164The string \verb|name| does not need to be a 2164The string \verb|name| does not need to be a
2165syntactically valid variable name. 2165syntactically valid variable name.
2166 2166
2167\subsubsection*{\ff \T{seterrormethod (newmethod)}}
2168\label{pdf-seterrormethod}
2169Sets the error handler \see{error}.
2170\verb|newmethod| must be a function or \nil,
2171in which case the error handler does nothing.
2172Returns the old error handler.
2173
2174\subsubsection*{\ff \T{settagmethod (tag, event, newmethod)}} 2167\subsubsection*{\ff \T{settagmethod (tag, event, newmethod)}}
2175\Deffunc{settagmethod} 2168\Deffunc{settagmethod}
2176This function sets a new tag method to the given pair \M{(tag, event)}. 2169This function sets a new tag method to the given pair \M{(tag, event)}.
@@ -2930,7 +2923,7 @@ so any existing program that opens at least one standard
2930library before calling Lua does not need to be modified. 2923library before calling Lua does not need to be modified.
2931 2924
2932\item Function \verb|dostring| no longer accepts an optional second argument, 2925\item Function \verb|dostring| no longer accepts an optional second argument,
2933with a temporary error method. 2926with a temporary error handler.
2934This facility is now provided by function \verb|call|. 2927This facility is now provided by function \verb|call|.
2935 2928
2936\item Function \verb|gsub| no longer accepts an optional fourth argument 2929\item Function \verb|gsub| no longer accepts an optional fourth argument
@@ -2951,8 +2944,10 @@ programs should use an explicit assignment instead, such as
2951 2944
2952\end{itemize} 2945\end{itemize}
2953 2946
2947% restore underscore to usual meaning
2948\catcode`\_=8
2949
2954\newcommand{\indexentry}[2]{\item {#1} #2} 2950\newcommand{\indexentry}[2]{\item {#1} #2}
2955%\catcode`\_=12
2956\begin{theindex} 2951\begin{theindex}
2957\input{manual.id} 2952\input{manual.id}
2958\end{theindex} 2953\end{theindex}