From 26679b1a48de4f7cfcde985764cb31c78ece4fc3 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 7 Jan 1998 14:26:48 -0200 Subject: back to upavalues as extra arguments for C closures; this way it's trivial to make currying. --- manual.tex | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'manual.tex') diff --git a/manual.tex b/manual.tex index 9966b9ba..18803118 100644 --- a/manual.tex +++ b/manual.tex @@ -1,4 +1,4 @@ -% $Id: manual.tex,v 1.1 1998/01/02 18:34:00 roberto Exp roberto $ +% $Id: manual.tex,v 1.2 1998/01/06 19:17:31 roberto Exp roberto $ \documentstyle[fullpage,11pt,bnf]{article} @@ -38,7 +38,7 @@ Waldemar Celes \tecgraf\ --- Computer Science Department --- PUC-Rio } -\date{\small \verb$Date: 1998/01/02 18:34:00 $} +\date{\small \verb$Date: 1998/01/06 19:17:31 $} \maketitle @@ -1647,7 +1647,8 @@ many results. When a C function is created, it is possible to associate some \emph{upvalues} to it; -then these values can be accessed by the function whenever it is called. +then these values are passed to the function whenever it is called, +as common arguments. To associate upvalues to a function, first these values must be pushed on C2lua. Then the function: @@ -1660,14 +1661,11 @@ with the argument \verb|n| telling how many upvalues must be associated with the function (notice that the macro \verb|lua_pushcfunction| is defined as \verb|lua_pushCclosure| with \verb|n| set to 0). -Any time the function \verb|fn| is called, -it can access those upvalues using: -\Deffunc{lua_upvalue} -\begin{verbatim} -lua_Object lua_upvalue (int n); -\end{verbatim} +Then, any time the function is called, +these upvalues are inserted as the first arguments to the function, +before the actual arguments provided in the call. -For some examples, see files \verb|lstrlib.c|, +For some examples of C functions, see files \verb|lstrlib.c|, \verb|liolib.c| and \verb|lmathlib.c| in Lua distribution. \subsection{References to Lua Objects} @@ -2080,7 +2078,7 @@ If \verb|i| is absent, then it is assumed to be 1. \subsubsection*{\ff \T{format (formatstring, e1, e2, \ldots)}}\Deffunc{format} \label{format} -This function returns a formated version of its variable number of arguments +This function returns a formatted version of its variable number of arguments following the description given in its first argument (which must be a string). The format string follows the same rules as the \verb|printf| family of standard C functions. @@ -2112,7 +2110,7 @@ decimal digit in the range [1,9], giving the position of the argument in the argument list. For instance, the call \verb|format("%2$d -> %1$03d", 1, 34)| will result in \verb|"34 -> 001"|. -The same argument can be used in more than one convertion. +The same argument can be used in more than one conversion. The options \verb|c|, \verb|d|, \verb|E|, \verb|e|, \verb|f|, \verb|g|, \verb|G|, \verb|i|, \verb|o|, \verb|u|, \verb|X|, and \verb|x| all @@ -2506,7 +2504,7 @@ It returns an error code, which is system-dependent. \subsubsection*{\ff \T{setlocale (locale [, category])}}\Deffunc{setlocale} This function is an interface to the ANSI C function \verb|setlocale|. -\verb|locale| is a string specifing a locale; +\verb|locale| is a string specifying a locale; \verb|category| is a number describing which category to change: 0 is \verb|LC_ALL|, 1 is \verb|LC_COLLATE|, 2 is \verb|LC_CTYPE|, 3 is \verb|LC_MONETARY|, 4 is \verb|LC_NUMERIC|, and 5 is \verb|LC_TIME|; @@ -2659,7 +2657,7 @@ This program can be called with any sequence of the following arguments: \item[\T{-e stat}] executes \verb|stat| as a Lua chunk. \item[\T{-i}] runs interactively, accepting commands from standard input until an \verb|EOF|. -Each line entered is immediatly executed. +Each line entered is immediately executed. \item[\T{-q}] same as \T{-i}, but without a prompt (quiet mode). \item[\T{-}] executes \verb|stdin| as a file. \item[\T{var=value}] sets global \verb|var| with string \verb|value|. @@ -2711,7 +2709,7 @@ Here is a list of all these incompatibilities. \begin{itemize} \item To support for multiple contexts, -the whole library must be explicitly openen before used. +the whole library must be explicitly opened before used. However, all standard libraries check whether Lua is already opened, so any program that opens at least one standard library before using Lua API does not need to be corrected. @@ -2727,7 +2725,7 @@ Closures make this feature irrelevant. \item The syntax for function declaration is now more restricted; for instance, the old syntax \verb|function f[exp] (x) ... end| is not accepted in 3.1. -Progams should use an explicit assignment instead, like this: +Programs should use an explicit assignment instead, like this: \verb|f[exp] = function (x) ... end|. \item Old pre-compiled code is obsolete, and must be re-compiled. -- cgit v1.2.3-55-g6feb