summaryrefslogtreecommitdiff
path: root/manual.tex
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-03-19 19:39:07 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-03-19 19:39:07 -0300
commite3c0ce9a6977c750eca72dcf173bcffaf01a11d7 (patch)
treed58ddaf36392ea747654b078c450fdfb1f8e9a15 /manual.tex
parent85b76bcc01141a118a22203798b7206d943ac072 (diff)
downloadlua-e3c0ce9a6977c750eca72dcf173bcffaf01a11d7.tar.gz
lua-e3c0ce9a6977c750eca72dcf173bcffaf01a11d7.tar.bz2
lua-e3c0ce9a6977c750eca72dcf173bcffaf01a11d7.zip
dofile accepts pre-compiled chunks.
lua_is... do coercion. small correction: = versus ==.
Diffstat (limited to 'manual.tex')
-rw-r--r--manual.tex33
1 files changed, 23 insertions, 10 deletions
diff --git a/manual.tex b/manual.tex
index a4a9c7c3..4828448a 100644
--- a/manual.tex
+++ b/manual.tex
@@ -1,4 +1,4 @@
1% $Id: manual.tex,v 1.11 1996/02/16 13:12:12 roberto Exp roberto $ 1% $Id: manual.tex,v 1.12 1996/03/14 17:45:01 roberto Exp roberto $
2 2
3\documentstyle[A4,11pt,bnf]{article} 3\documentstyle[A4,11pt,bnf]{article}
4 4
@@ -13,7 +13,7 @@
13\newcommand{\Def}[1]{{\em #1}\index{#1}} 13\newcommand{\Def}[1]{{\em #1}\index{#1}}
14\newcommand{\Deffunc}[1]{\index{#1}} 14\newcommand{\Deffunc}[1]{\index{#1}}
15 15
16\newcommand{\Version}{2.3} 16\newcommand{\Version}{2.4}
17 17
18\makeindex 18\makeindex
19 19
@@ -34,7 +34,7 @@ Waldemar Celes Filho
34\tecgraf\ --- Departamento de Inform\'atica --- PUC-Rio 34\tecgraf\ --- Departamento de Inform\'atica --- PUC-Rio
35} 35}
36 36
37\date{\small \verb$Date: 1996/02/16 13:12:12 $} 37\date{\small \verb$Date: 1996/03/14 17:45:01 $}
38 38
39\maketitle 39\maketitle
40 40
@@ -137,7 +137,11 @@ of new functions%
137\footnote{Actually, a function definition is an 137\footnote{Actually, a function definition is an
138assignment to a global variable; \see{TypesSec}.}. 138assignment to a global variable; \see{TypesSec}.}.
139 139
140 140Chunks may be pre-compiled; see program \IndexVerb{luac} for details.
141Ascii files with chunk code and their binary pre-compiled forms
142are interchangeable.
143Lua automatically detects the file type and acts accordingly.
144\index{pre-compilation}
141 145
142\section{\Index{Types}} \label{TypesSec} 146\section{\Index{Types}} \label{TypesSec}
143 147
@@ -412,7 +416,7 @@ Otherwise, their values are compared.
412Numbers and strings are compared in the usual way. 416Numbers and strings are compared in the usual way.
413Tables, CFunctions, and functions are compared by reference, 417Tables, CFunctions, and functions are compared by reference,
414that is, two tables are considered equal only if they are the same table. 418that is, two tables are considered equal only if they are the same table.
415The operator \verb'~=' is exactly the negation of equality (\verb'='). 419The operator \verb'~=' is exactly the negation of equality (\verb'==').
416 420
417The other operators work as follows. 421The other operators work as follows.
418If both arguments are numbers, they are compared as such. 422If both arguments are numbers, they are compared as such.
@@ -444,7 +448,7 @@ Otherwise, the fallback ``concat'' is called; \see{fallback}.
444from the lower to the higher priority: 448from the lower to the higher priority:
445\begin{verbatim} 449\begin{verbatim}
446 and or 450 and or
447 < > <= >= ~= = 451 < > <= >= ~= ==
448 .. 452 ..
449 + - 453 + -
450 * / 454 * /
@@ -740,7 +744,7 @@ The API functions can be classified in the following categories:
740All API functions are declared in the file \verb'lua.h'. 744All API functions are declared in the file \verb'lua.h'.
741 745
742\subsection{Executing Lua Code} 746\subsection{Executing Lua Code}
743A host program can execute Lua programs written in a file or in a string, 747A host program can execute Lua chunks written in a file or in a string,
744using the following functions: 748using the following functions:
745\Deffunc{lua_dofile}\Deffunc{lua_dostring} 749\Deffunc{lua_dofile}\Deffunc{lua_dostring}
746\begin{verbatim} 750\begin{verbatim}
@@ -751,6 +755,9 @@ Both functions return an error code:
7510, in case of success; non zero, in case of errors. 7550, in case of success; non zero, in case of errors.
752The function \verb'lua_dofile', if called with argument NULL (0), 756The function \verb'lua_dofile', if called with argument NULL (0),
753executes the ``file'' {\tt stdin}. 757executes the ``file'' {\tt stdin}.
758Function \verb'lua_dofile' is also able to execute pre-compiled chunks.
759It detects whether the file is text or not,
760and loads it accordingly (see program \IndexVerb{luac}).
754 761
755\subsection{Converting Values between C and Lua} \label{valuesCLua} 762\subsection{Converting Values between C and Lua} \label{valuesCLua}
756Because Lua has no static type system, 763Because Lua has no static type system,
@@ -788,19 +795,24 @@ the following function is available:
788\begin{verbatim} 795\begin{verbatim}
789int lua_type (lua_Object object); 796int lua_type (lua_Object object);
790\end{verbatim} 797\end{verbatim}
791plus the following macros: 798plus the following macros and functions:
792\Deffunc{lua_isnil}\Deffunc{lua_isnumber}\Deffunc{lua_isstring} 799\Deffunc{lua_isnil}\Deffunc{lua_isnumber}\Deffunc{lua_isstring}
793\Deffunc{lua_istable}\Deffunc{lua_iscfunction}\Deffunc{lua_isuserdata} 800\Deffunc{lua_istable}\Deffunc{lua_iscfunction}\Deffunc{lua_isuserdata}
801\Deffunc{lua_isfunction}
794\begin{verbatim} 802\begin{verbatim}
795int lua_isnil (lua_Object object); 803int lua_isnil (lua_Object object);
796int lua_isnumber (lua_Object object); 804int lua_isnumber (lua_Object object);
797int lua_isstring (lua_Object object); 805int lua_isstring (lua_Object object);
798int lua_istable (lua_Object object); 806int lua_istable (lua_Object object);
807int lua_isfunction (lua_Object object);
799int lua_iscfunction (lua_Object object); 808int lua_iscfunction (lua_Object object);
800int lua_isuserdata (lua_Object object); 809int lua_isuserdata (lua_Object object);
801\end{verbatim} 810\end{verbatim}
802All macros return 1 if the object has the given type, 811All macros return 1 if the object is compatible with the given type,
803and 0 otherwise. 812and 0 otherwise.
813\verb'lua_isnumber' accepts numbers and numerical strings,
814\verb'lua_isstring' accepts strings and numbers (\see{coercion}),
815and \verb'lua_isfunction' accepts Lua and C functions.
804 816
805The function \verb'lua_type' can be used to distinguish between 817The function \verb'lua_type' can be used to distinguish between
806different kinds of user data; see below. 818different kinds of user data; see below.
@@ -1113,7 +1125,8 @@ declared in \verb-lualib.h-.
1113 1125
1114\subsubsection*{{\tt dofile (filename)}}\Deffunc{dofile} 1126\subsubsection*{{\tt dofile (filename)}}\Deffunc{dofile}
1115This function receives a file name, 1127This function receives a file name,
1116opens it and executes its contents as a Lua chunk. 1128opens it and executes its contents as a Lua chunk,
1129or as pre-compiled chunks.
1117When called without arguments, 1130When called without arguments,
1118it executes the contents of the standard input. 1131it executes the contents of the standard input.
1119It returns 1 if there are no errors, \nil\ otherwise. 1132It returns 1 if there are no errors, \nil\ otherwise.