summaryrefslogtreecommitdiff
path: root/manual.tex
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-01-07 14:26:48 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-01-07 14:26:48 -0200
commit26679b1a48de4f7cfcde985764cb31c78ece4fc3 (patch)
treedf30c6972204791dd6a792dd36c1dd132bc5dbf4 /manual.tex
parente04c2b9aa817ed59b4e05025e0d33bfb3bba8f59 (diff)
downloadlua-26679b1a48de4f7cfcde985764cb31c78ece4fc3.tar.gz
lua-26679b1a48de4f7cfcde985764cb31c78ece4fc3.tar.bz2
lua-26679b1a48de4f7cfcde985764cb31c78ece4fc3.zip
back to upavalues as extra arguments for C closures; this way it's
trivial to make currying.
Diffstat (limited to 'manual.tex')
-rw-r--r--manual.tex30
1 files changed, 14 insertions, 16 deletions
diff --git a/manual.tex b/manual.tex
index 9966b9ba..18803118 100644
--- a/manual.tex
+++ b/manual.tex
@@ -1,4 +1,4 @@
1% $Id: manual.tex,v 1.1 1998/01/02 18:34:00 roberto Exp roberto $ 1% $Id: manual.tex,v 1.2 1998/01/06 19:17:31 roberto Exp roberto $
2 2
3\documentstyle[fullpage,11pt,bnf]{article} 3\documentstyle[fullpage,11pt,bnf]{article}
4 4
@@ -38,7 +38,7 @@ Waldemar Celes
38\tecgraf\ --- Computer Science Department --- PUC-Rio 38\tecgraf\ --- Computer Science Department --- PUC-Rio
39} 39}
40 40
41\date{\small \verb$Date: 1998/01/02 18:34:00 $} 41\date{\small \verb$Date: 1998/01/06 19:17:31 $}
42 42
43\maketitle 43\maketitle
44 44
@@ -1647,7 +1647,8 @@ many results.
1647 1647
1648When a C function is created, 1648When a C function is created,
1649it is possible to associate some \emph{upvalues} to it; 1649it is possible to associate some \emph{upvalues} to it;
1650then these values can be accessed by the function whenever it is called. 1650then these values are passed to the function whenever it is called,
1651as common arguments.
1651To associate upvalues to a function, 1652To associate upvalues to a function,
1652first these values must be pushed on C2lua. 1653first these values must be pushed on C2lua.
1653Then the function: 1654Then the function:
@@ -1660,14 +1661,11 @@ with the argument \verb|n| telling how many upvalues must be
1660associated with the function 1661associated with the function
1661(notice that the macro \verb|lua_pushcfunction| is defined as 1662(notice that the macro \verb|lua_pushcfunction| is defined as
1662\verb|lua_pushCclosure| with \verb|n| set to 0). 1663\verb|lua_pushCclosure| with \verb|n| set to 0).
1663Any time the function \verb|fn| is called, 1664Then, any time the function is called,
1664it can access those upvalues using: 1665these upvalues are inserted as the first arguments to the function,
1665\Deffunc{lua_upvalue} 1666before the actual arguments provided in the call.
1666\begin{verbatim}
1667lua_Object lua_upvalue (int n);
1668\end{verbatim}
1669 1667
1670For some examples, see files \verb|lstrlib.c|, 1668For some examples of C functions, see files \verb|lstrlib.c|,
1671\verb|liolib.c| and \verb|lmathlib.c| in Lua distribution. 1669\verb|liolib.c| and \verb|lmathlib.c| in Lua distribution.
1672 1670
1673\subsection{References to Lua Objects} 1671\subsection{References to Lua Objects}
@@ -2080,7 +2078,7 @@ If \verb|i| is absent, then it is assumed to be 1.
2080 2078
2081\subsubsection*{\ff \T{format (formatstring, e1, e2, \ldots)}}\Deffunc{format} 2079\subsubsection*{\ff \T{format (formatstring, e1, e2, \ldots)}}\Deffunc{format}
2082\label{format} 2080\label{format}
2083This function returns a formated version of its variable number of arguments 2081This function returns a formatted version of its variable number of arguments
2084following the description given in its first argument (which must be a string). 2082following the description given in its first argument (which must be a string).
2085The format string follows the same rules as the \verb|printf| family of 2083The format string follows the same rules as the \verb|printf| family of
2086standard C functions. 2084standard C functions.
@@ -2112,7 +2110,7 @@ decimal digit in the range [1,9],
2112giving the position of the argument in the argument list. 2110giving the position of the argument in the argument list.
2113For instance, the call \verb|format("%2$d -> %1$03d", 1, 34)| will 2111For instance, the call \verb|format("%2$d -> %1$03d", 1, 34)| will
2114result in \verb|"34 -> 001"|. 2112result in \verb|"34 -> 001"|.
2115The same argument can be used in more than one convertion. 2113The same argument can be used in more than one conversion.
2116 2114
2117The options \verb|c|, \verb|d|, \verb|E|, \verb|e|, \verb|f|, 2115The options \verb|c|, \verb|d|, \verb|E|, \verb|e|, \verb|f|,
2118\verb|g|, \verb|G|, \verb|i|, \verb|o|, \verb|u|, \verb|X|, and \verb|x| all 2116\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.
2506\subsubsection*{\ff \T{setlocale (locale [, category])}}\Deffunc{setlocale} 2504\subsubsection*{\ff \T{setlocale (locale [, category])}}\Deffunc{setlocale}
2507 2505
2508This function is an interface to the ANSI C function \verb|setlocale|. 2506This function is an interface to the ANSI C function \verb|setlocale|.
2509\verb|locale| is a string specifing a locale; 2507\verb|locale| is a string specifying a locale;
2510\verb|category| is a number describing which category to change: 2508\verb|category| is a number describing which category to change:
25110 is \verb|LC_ALL|, 1 is \verb|LC_COLLATE|, 2 is \verb|LC_CTYPE|, 25090 is \verb|LC_ALL|, 1 is \verb|LC_COLLATE|, 2 is \verb|LC_CTYPE|,
25123 is \verb|LC_MONETARY|, 4 is \verb|LC_NUMERIC|, and 5 is \verb|LC_TIME|; 25103 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:
2659\item[\T{-e stat}] executes \verb|stat| as a Lua chunk. 2657\item[\T{-e stat}] executes \verb|stat| as a Lua chunk.
2660\item[\T{-i}] runs interactively, 2658\item[\T{-i}] runs interactively,
2661accepting commands from standard input until an \verb|EOF|. 2659accepting commands from standard input until an \verb|EOF|.
2662Each line entered is immediatly executed. 2660Each line entered is immediately executed.
2663\item[\T{-q}] same as \T{-i}, but without a prompt (quiet mode). 2661\item[\T{-q}] same as \T{-i}, but without a prompt (quiet mode).
2664\item[\T{-}] executes \verb|stdin| as a file. 2662\item[\T{-}] executes \verb|stdin| as a file.
2665\item[\T{var=value}] sets global \verb|var| with string \verb|value|. 2663\item[\T{var=value}] sets global \verb|var| with string \verb|value|.
@@ -2711,7 +2709,7 @@ Here is a list of all these incompatibilities.
2711\begin{itemize} 2709\begin{itemize}
2712 2710
2713\item To support for multiple contexts, 2711\item To support for multiple contexts,
2714the whole library must be explicitly openen before used. 2712the whole library must be explicitly opened before used.
2715However, all standard libraries check whether Lua is already opened, 2713However, all standard libraries check whether Lua is already opened,
2716so any program that opens at least one standard library before using 2714so any program that opens at least one standard library before using
2717Lua API does not need to be corrected. 2715Lua API does not need to be corrected.
@@ -2727,7 +2725,7 @@ Closures make this feature irrelevant.
2727\item The syntax for function declaration is now more restricted; 2725\item The syntax for function declaration is now more restricted;
2728for instance, the old syntax \verb|function f[exp] (x) ... end| is not 2726for instance, the old syntax \verb|function f[exp] (x) ... end| is not
2729accepted in 3.1. 2727accepted in 3.1.
2730Progams should use an explicit assignment instead, like this: 2728Programs should use an explicit assignment instead, like this:
2731\verb|f[exp] = function (x) ... end|. 2729\verb|f[exp] = function (x) ... end|.
2732 2730
2733\item Old pre-compiled code is obsolete, and must be re-compiled. 2731\item Old pre-compiled code is obsolete, and must be re-compiled.