summaryrefslogtreecommitdiff
path: root/manual.tex
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-10-04 15:51:04 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-10-04 15:51:04 -0200
commit4343420d4d559a7d4cdacdbc1fd61552dcf59f04 (patch)
tree57e0bdd41e2f3a4ab70d3150022569751e3d02ad /manual.tex
parent1f7103e05d01a6a4c300a73bcfc8d9b17b2c20a4 (diff)
downloadlua-4343420d4d559a7d4cdacdbc1fd61552dcf59f04.tar.gz
lua-4343420d4d559a7d4cdacdbc1fd61552dcf59f04.tar.bz2
lua-4343420d4d559a7d4cdacdbc1fd61552dcf59f04.zip
simplified version of `gc' tag method (only for userdata now).
Diffstat (limited to 'manual.tex')
-rw-r--r--manual.tex61
1 files changed, 52 insertions, 9 deletions
diff --git a/manual.tex b/manual.tex
index e8c3b6a5..ba9af4ff 100644
--- a/manual.tex
+++ b/manual.tex
@@ -1,4 +1,4 @@
1% $Id: manual.tex,v 1.32 1999/05/11 20:46:28 roberto Exp roberto $ 1% $Id: manual.tex,v 1.33 1999/05/27 20:21:03 roberto Exp roberto $
2 2
3\documentclass[11pt]{article} 3\documentclass[11pt]{article}
4\usepackage{fullpage,bnf} 4\usepackage{fullpage,bnf}
@@ -41,7 +41,7 @@ Waldemar Celes
41\tecgraf\ --- Computer Science Department --- PUC-Rio 41\tecgraf\ --- Computer Science Department --- PUC-Rio
42} 42}
43 43
44\date{{\small \tt\$Date: 1999/05/11 20:46:28 $ $}} 44\date{{\small \tt\$Date: 1999/05/27 20:21:03 $ $}}
45 45
46\maketitle 46\maketitle
47 47
@@ -1273,7 +1273,8 @@ is terminated, returning an error condition.
1273 1273
1274The only argument to \verb|_ERRORMESSAGE| is a string 1274The only argument to \verb|_ERRORMESSAGE| is a string
1275describing the error. 1275describing the error.
1276The default definition for this function calls \verb|_ALERT|, 1276The default definition for
1277this function calls \verb|_ALERT|, \Deffunc{_ALERT}
1277which prints the message to \verb|stderr| \see{alert}. 1278which prints the message to \verb|stderr| \see{alert}.
1278The standard I/O library redefines \verb|_ERRORMESSAGE|, 1279The standard I/O library redefines \verb|_ERRORMESSAGE|,
1279and uses the debug facilities \see{debugI} 1280and uses the debug facilities \see{debugI}
@@ -1835,6 +1836,8 @@ void lua_unref (int ref);
1835The function \verb|lua_ref| creates a reference 1836The function \verb|lua_ref| creates a reference
1836to the object that is on the top of the stack, 1837to the object that is on the top of the stack,
1837and returns this reference. 1838and returns this reference.
1839For a \nil{} object, the reference is always -1;
1840otherwise, it is a non-negative integer.
1838If \verb|lock| is true, the object is \emph{locked}: 1841If \verb|lock| is true, the object is \emph{locked}:
1839this means the object will not be garbage collected. 1842this means the object will not be garbage collected.
1840Note that an unlocked reference may be garbage collected. 1843Note that an unlocked reference may be garbage collected.
@@ -2503,26 +2506,32 @@ The following combinations are allowed in describing a character class:
2503\item[\T{\%s}] --- represents all space characters. 2506\item[\T{\%s}] --- represents all space characters.
2504\item[\T{\%u}] --- represents all upper case letters. 2507\item[\T{\%u}] --- represents all upper case letters.
2505\item[\T{\%w}] --- represents all alphanumeric characters. 2508\item[\T{\%w}] --- represents all alphanumeric characters.
2506\item[\T{\%x}] --- represents all hexa-decimal digits. 2509\item[\T{\%x}] --- represents all hexadecimal digits.
2507\item[\T{\%z}] --- represents the character with representation 0. 2510\item[\T{\%z}] --- represents the character with representation 0.
2508\item[\T{\%\M{x}}] (where \M{x} is any non alphanumeric character) --- 2511\item[\T{\%\M{x}}] (where \M{x} is any non alphanumeric character) ---
2509represents the character \M{x}. 2512represents the character \M{x}.
2510This is the standard way to escape the magic characters \verb|()%.[]*-?|. 2513This is the standard way to escape the magic characters \verb|()%.[]*-?|.
2511It is strongly recommended that any control character (even the non magic), 2514It is strongly recommended that any control character (even the non magic),
2512when used to represent itself in a pattern, should be preceded by a \verb|%|. 2515when used to represent itself in a pattern, should be preceded by a \verb|%|.
2516
2513\item[\T{[char-set]}] --- 2517\item[\T{[char-set]}] ---
2514Represents the class which is the union of all 2518Represents the class which is the union of all
2515characters in char-set. 2519characters in char-set.
2516To include a \verb|]| in char-set, it must be the first character.
2517A range of characters may be specified by 2520A range of characters may be specified by
2518separating the end characters of the range with a \verb|-|. 2521separating the end characters of the range with a \verb|-|.
2519If \verb|-| appears as the first or last character of char-set,
2520then it represents itself.
2521All classes \verb|%|\emph{x} described above can also be used as 2522All classes \verb|%|\emph{x} described above can also be used as
2522components in a char-set. 2523components in a char-set.
2523All other characters in char-set represent themselves. 2524All other characters in char-set represent themselves.
2524E.g., assuming an \emph{ascii} character set, 2525E.g., \verb|[%w_]| (or \verb|[_%w]|)
2525\verb|[%dA-Fa-f]| specifies the hexa-decimal digits. 2526represents all alphanumeric characters plus the underscore,
2527\verb|[0-7]| represents the octal digits,
2528and \verb|[0-7%l%-]| represents the octal digits plus
2529the lower case letters plus the \verb|-| character.
2530
2531The interaction between ranges and classes is not defined.
2532Therefore, patterns like \verb|[%a-z]| or \verb|[a-%%]|
2533have no meaning.
2534
2526\item[\T{[\^{ }char-set]}] --- 2535\item[\T{[\^{ }char-set]}] ---
2527represents the complement of char-set, 2536represents the complement of char-set,
2528where char-set is interpreted as above. 2537where char-set is interpreted as above.
@@ -3187,6 +3196,8 @@ accepting commands from standard input until an \verb|EOF|.
3187Each line entered is immediately executed. 3196Each line entered is immediately executed.
3188\item[\T{-q}] same as \T{-i}, but without a prompt (quiet mode). 3197\item[\T{-q}] same as \T{-i}, but without a prompt (quiet mode).
3189\item[\T{-}] executes \verb|stdin| as a file. 3198\item[\T{-}] executes \verb|stdin| as a file.
3199\item[\T{--}] stops the execution of arguments;
3200all arguments after it are simply passed to the Lua script.
3190\item[\T{var=value}] sets global \verb|var| with string \verb|"value"|. 3201\item[\T{var=value}] sets global \verb|var| with string \verb|"value"|.
3191\item[\T{filename}] executes file \verb|filename| as a Lua chunk. 3202\item[\T{filename}] executes file \verb|filename| as a Lua chunk.
3192\end{description} 3203\end{description}
@@ -3203,6 +3214,37 @@ will first interact with the user until an \verb|EOF|,
3203then will set \verb|a| to \verb|"test"|, 3214then will set \verb|a| to \verb|"test"|,
3204and finally will run the file \verb|prog.lua|. 3215and finally will run the file \verb|prog.lua|.
3205 3216
3217All arguments from the command line are passed to the Lua program in
3218a table called \verb|arg|.
3219If the command line has the \verb|--| argument,
3220this argument is at index 0;
3221the arguments after it get indices 1, 2, \ldots;
3222and the arguments before it get negative indices.
3223The field \verb|n| gets the index of the last argument,
3224and the field \verb|nn| gets the index of the first argument
3225(always a negative number).
3226For instance:
3227\begin{verbatim}
3228$ lua -e "foreach(arg, print)" -- a b
3229-1 foreach(arg, print)
3230-2 -e
3231-3 lua
32320 --
32331 a
32342 b
3235nn -3
3236n 2
3237\end{verbatim}
3238If the command line has no \verb|--| argument,
3239all arguments have negative indices, with the last one at position -1.
3240As a general rule, if you want to traverse all the
3241arguments after the \verb|--|, you loop from 1 to \verb|arg.n|
3242(you can use the \verb|foreachi| function, for instance).
3243If you want to traverse all arguments,
3244you loop from \verb|arg.nn| until \verb|arg.n|.
3245In any case, you may call \verb|exit| at the end of a script,
3246to stop Lua from running the other arguments.
3247
3206When in interactive mode, 3248When in interactive mode,
3207a multi-line statement can be written finishing intermediate 3249a multi-line statement can be written finishing intermediate
3208lines with a backslash (\verb|\|). 3250lines with a backslash (\verb|\|).
@@ -3216,6 +3258,7 @@ In Unix systems, Lua scripts can be made into executable programs
3216by using the \verb|#!| form, 3258by using the \verb|#!| form,
3217as in \verb|#!/usr/local/bin/lua|. 3259as in \verb|#!/usr/local/bin/lua|.
3218 3260
3261
3219\section*{Acknowledgments} 3262\section*{Acknowledgments}
3220 3263
3221The authors would like to thank CENPES/PETROBRAS which, 3264The authors would like to thank CENPES/PETROBRAS which,