diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-10-04 15:51:04 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-10-04 15:51:04 -0200 |
commit | 4343420d4d559a7d4cdacdbc1fd61552dcf59f04 (patch) | |
tree | 57e0bdd41e2f3a4ab70d3150022569751e3d02ad /manual.tex | |
parent | 1f7103e05d01a6a4c300a73bcfc8d9b17b2c20a4 (diff) | |
download | lua-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.tex | 61 |
1 files changed, 52 insertions, 9 deletions
@@ -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 | ||
1274 | The only argument to \verb|_ERRORMESSAGE| is a string | 1274 | The only argument to \verb|_ERRORMESSAGE| is a string |
1275 | describing the error. | 1275 | describing the error. |
1276 | The default definition for this function calls \verb|_ALERT|, | 1276 | The default definition for |
1277 | this function calls \verb|_ALERT|, \Deffunc{_ALERT} | ||
1277 | which prints the message to \verb|stderr| \see{alert}. | 1278 | which prints the message to \verb|stderr| \see{alert}. |
1278 | The standard I/O library redefines \verb|_ERRORMESSAGE|, | 1279 | The standard I/O library redefines \verb|_ERRORMESSAGE|, |
1279 | and uses the debug facilities \see{debugI} | 1280 | and uses the debug facilities \see{debugI} |
@@ -1835,6 +1836,8 @@ void lua_unref (int ref); | |||
1835 | The function \verb|lua_ref| creates a reference | 1836 | The function \verb|lua_ref| creates a reference |
1836 | to the object that is on the top of the stack, | 1837 | to the object that is on the top of the stack, |
1837 | and returns this reference. | 1838 | and returns this reference. |
1839 | For a \nil{} object, the reference is always -1; | ||
1840 | otherwise, it is a non-negative integer. | ||
1838 | If \verb|lock| is true, the object is \emph{locked}: | 1841 | If \verb|lock| is true, the object is \emph{locked}: |
1839 | this means the object will not be garbage collected. | 1842 | this means the object will not be garbage collected. |
1840 | Note that an unlocked reference may be garbage collected. | 1843 | Note 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) --- |
2509 | represents the character \M{x}. | 2512 | represents the character \M{x}. |
2510 | This is the standard way to escape the magic characters \verb|()%.[]*-?|. | 2513 | This is the standard way to escape the magic characters \verb|()%.[]*-?|. |
2511 | It is strongly recommended that any control character (even the non magic), | 2514 | It is strongly recommended that any control character (even the non magic), |
2512 | when used to represent itself in a pattern, should be preceded by a \verb|%|. | 2515 | when used to represent itself in a pattern, should be preceded by a \verb|%|. |
2516 | |||
2513 | \item[\T{[char-set]}] --- | 2517 | \item[\T{[char-set]}] --- |
2514 | Represents the class which is the union of all | 2518 | Represents the class which is the union of all |
2515 | characters in char-set. | 2519 | characters in char-set. |
2516 | To include a \verb|]| in char-set, it must be the first character. | ||
2517 | A range of characters may be specified by | 2520 | A range of characters may be specified by |
2518 | separating the end characters of the range with a \verb|-|. | 2521 | separating the end characters of the range with a \verb|-|. |
2519 | If \verb|-| appears as the first or last character of char-set, | ||
2520 | then it represents itself. | ||
2521 | All classes \verb|%|\emph{x} described above can also be used as | 2522 | All classes \verb|%|\emph{x} described above can also be used as |
2522 | components in a char-set. | 2523 | components in a char-set. |
2523 | All other characters in char-set represent themselves. | 2524 | All other characters in char-set represent themselves. |
2524 | E.g., assuming an \emph{ascii} character set, | 2525 | E.g., \verb|[%w_]| (or \verb|[_%w]|) |
2525 | \verb|[%dA-Fa-f]| specifies the hexa-decimal digits. | 2526 | represents all alphanumeric characters plus the underscore, |
2527 | \verb|[0-7]| represents the octal digits, | ||
2528 | and \verb|[0-7%l%-]| represents the octal digits plus | ||
2529 | the lower case letters plus the \verb|-| character. | ||
2530 | |||
2531 | The interaction between ranges and classes is not defined. | ||
2532 | Therefore, patterns like \verb|[%a-z]| or \verb|[a-%%]| | ||
2533 | have no meaning. | ||
2534 | |||
2526 | \item[\T{[\^{ }char-set]}] --- | 2535 | \item[\T{[\^{ }char-set]}] --- |
2527 | represents the complement of char-set, | 2536 | represents the complement of char-set, |
2528 | where char-set is interpreted as above. | 2537 | where char-set is interpreted as above. |
@@ -3187,6 +3196,8 @@ accepting commands from standard input until an \verb|EOF|. | |||
3187 | Each line entered is immediately executed. | 3196 | Each 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; | ||
3200 | all 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|, | |||
3203 | then will set \verb|a| to \verb|"test"|, | 3214 | then will set \verb|a| to \verb|"test"|, |
3204 | and finally will run the file \verb|prog.lua|. | 3215 | and finally will run the file \verb|prog.lua|. |
3205 | 3216 | ||
3217 | All arguments from the command line are passed to the Lua program in | ||
3218 | a table called \verb|arg|. | ||
3219 | If the command line has the \verb|--| argument, | ||
3220 | this argument is at index 0; | ||
3221 | the arguments after it get indices 1, 2, \ldots; | ||
3222 | and the arguments before it get negative indices. | ||
3223 | The field \verb|n| gets the index of the last argument, | ||
3224 | and the field \verb|nn| gets the index of the first argument | ||
3225 | (always a negative number). | ||
3226 | For instance: | ||
3227 | \begin{verbatim} | ||
3228 | $ lua -e "foreach(arg, print)" -- a b | ||
3229 | -1 foreach(arg, print) | ||
3230 | -2 -e | ||
3231 | -3 lua | ||
3232 | 0 -- | ||
3233 | 1 a | ||
3234 | 2 b | ||
3235 | nn -3 | ||
3236 | n 2 | ||
3237 | \end{verbatim} | ||
3238 | If the command line has no \verb|--| argument, | ||
3239 | all arguments have negative indices, with the last one at position -1. | ||
3240 | As a general rule, if you want to traverse all the | ||
3241 | arguments after the \verb|--|, you loop from 1 to \verb|arg.n| | ||
3242 | (you can use the \verb|foreachi| function, for instance). | ||
3243 | If you want to traverse all arguments, | ||
3244 | you loop from \verb|arg.nn| until \verb|arg.n|. | ||
3245 | In any case, you may call \verb|exit| at the end of a script, | ||
3246 | to stop Lua from running the other arguments. | ||
3247 | |||
3206 | When in interactive mode, | 3248 | When in interactive mode, |
3207 | a multi-line statement can be written finishing intermediate | 3249 | a multi-line statement can be written finishing intermediate |
3208 | lines with a backslash (\verb|\|). | 3250 | lines with a backslash (\verb|\|). |
@@ -3216,6 +3258,7 @@ In Unix systems, Lua scripts can be made into executable programs | |||
3216 | by using the \verb|#!| form, | 3258 | by using the \verb|#!| form, |
3217 | as in \verb|#!/usr/local/bin/lua|. | 3259 | as in \verb|#!/usr/local/bin/lua|. |
3218 | 3260 | ||
3261 | |||
3219 | \section*{Acknowledgments} | 3262 | \section*{Acknowledgments} |
3220 | 3263 | ||
3221 | The authors would like to thank CENPES/PETROBRAS which, | 3264 | The authors would like to thank CENPES/PETROBRAS which, |