aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-06-20 16:28:16 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-06-20 16:28:16 -0300
commit3e4327530835f65d3bc089688bd46f44efcddb57 (patch)
treee53ad5f3e1d741156d646f09eb353bbe8851deaa
parentf97307b54893a53c985a0dcd8b3bb2b94cedd48d (diff)
downloadlua-3e4327530835f65d3bc089688bd46f44efcddb57.tar.gz
lua-3e4327530835f65d3bc089688bd46f44efcddb57.tar.bz2
lua-3e4327530835f65d3bc089688bd46f44efcddb57.zip
incompatibilities with 2.5 + restrictions on tag methods
-rw-r--r--manual.tex68
1 files changed, 48 insertions, 20 deletions
diff --git a/manual.tex b/manual.tex
index a1d6fd99..210721b2 100644
--- a/manual.tex
+++ b/manual.tex
@@ -1,4 +1,4 @@
1% $Id: manual.tex,v 2.3 1997/06/19 18:03:04 roberto Exp roberto $ 1% $Id: manual.tex,v 2.4 1997/06/19 18:49:40 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: 1997/06/19 18:03:04 $} 41\date{\small \verb$Date: 1997/06/19 18:49:40 $}
42 42
43\maketitle 43\maketitle
44 44
@@ -973,6 +973,8 @@ See event \verb|"gettable"| for its semantics.
973 973
974\item[``getglobal'':]\index{getglobal event} 974\item[``getglobal'':]\index{getglobal event}
975called whenever Lua accesses a global variable. 975called whenever Lua accesses a global variable.
976This method can only be set for \nil\ and for tags
977created by \verb|newtag|.
976\begin{verbatim} 978\begin{verbatim}
977 function getglobal (varname) 979 function getglobal (varname)
978 local value = rawgetglobal(varname) 980 local value = rawgetglobal(varname)
@@ -988,6 +990,8 @@ Notice: the function \verb|getglobal| is pre-defined in Lua \see{predefined}.
988 990
989\item[``setglobal'':]\index{setglobal event} 991\item[``setglobal'':]\index{setglobal event}
990called whenever Lua assigns to a global variable. 992called whenever Lua assigns to a global variable.
993This method cannot be set for numbers, strings, and tables and
994userdata with default tags.
991\begin{verbatim} 995\begin{verbatim}
992 function setglobal (varname, newvalue) 996 function setglobal (varname, newvalue)
993 local oldvalue = rawgetglobal(varname) 997 local oldvalue = rawgetglobal(varname)
@@ -1003,6 +1007,7 @@ Notice: the function \verb|setglobal| is pre-defined in Lua \see{predefined}.
1003 1007
1004\item[``gettable'':]\index{gettable event} 1008\item[``gettable'':]\index{gettable event}
1005called whenever Lua accesses an indexed variable. 1009called whenever Lua accesses an indexed variable.
1010This method cannot be set for tables with default tag.
1006\begin{verbatim} 1011\begin{verbatim}
1007 function gettable_event (table, index) 1012 function gettable_event (table, index)
1008 local tm = gettagmethod(tag(table), "gettable") 1013 local tm = gettagmethod(tag(table), "gettable")
@@ -1024,6 +1029,7 @@ called whenever Lua accesses an indexed variable.
1024 1029
1025\item[``settable'':]\index{settable event} 1030\item[``settable'':]\index{settable event}
1026called when Lua assigns to an indexed variable. 1031called when Lua assigns to an indexed variable.
1032This method cannot be set for tables with default tag.
1027\begin{verbatim} 1033\begin{verbatim}
1028 function settable_event (table, index, value) 1034 function settable_event (table, index, value)
1029 local tm = gettagmethod(tag(table), "settable") 1035 local tm = gettagmethod(tag(table), "settable")
@@ -1063,6 +1069,8 @@ called when Lua tries to call a non function value.
1063 1069
1064\item[``gc'':]\index{gc event} 1070\item[``gc'':]\index{gc event}
1065called when Lua is garbage collecting an object. 1071called when Lua is garbage collecting an object.
1072This method cannot be set for strings, numbers, functions,
1073and userdata with default tag.
1066For each object to be collected, 1074For each object to be collected,
1067Lua does the equivalent of the following function: 1075Lua does the equivalent of the following function:
1068\begin{verbatim} 1076\begin{verbatim}
@@ -1092,20 +1100,22 @@ is terminated returning an error condition.
1092 1100
1093The only argument to the error method is a string 1101The only argument to the error method is a string
1094describing the error. 1102describing the error.
1095The standard I/O library redefines this method, 1103The default method prints this message in \verb|stderr|.
1104If needed, it is possible to change the error method with the
1105function \verb|seterrormethod|,
1106which gets the new error handler as its only parameter
1107\see{pdf-seterrormethod}.
1108The standard I/O library uses this facility to redefine the error method,
1096using the debug facilities \see{debugI}, 1109using the debug facilities \see{debugI},
1097in order to print some extra information, 1110in order to print some extra information,
1098like the call stack. 1111like the call stack.
1112
1099To provide more information about errors, 1113To provide more information about errors,
1100Lua programs should include the compilation pragma \verb|$debug|. 1114Lua programs should include the compilation pragma \verb|$debug|.
1101\index{debug pragma}\label{pragma} 1115\index{debug pragma}\label{pragma}
1102When an error occurs in a program compiled with this option, 1116When an error occurs in a program compiled with this option,
1103the error routine is able to print the number of the lines where the calls 1117the I/O error routine is able to print the number of the
1104(and the error) were made. 1118lines where the calls (and the error) were made.
1105If needed, it is possible to change the error method with the
1106function \verb|seterrormethod|,
1107which gets the new error handler as its only parameter
1108\see{pdf-seterrormethod}.
1109 1119
1110Lua code can explicitly generate an error by calling the built-in 1120Lua code can explicitly generate an error by calling the built-in
1111function \verb|error| \see{pdf-error}. 1121function \verb|error| \see{pdf-error}.
@@ -1430,13 +1440,14 @@ pops all elements from the C2lua stack.
1430The following example shows how a C program may do the 1440The following example shows how a C program may do the
1431equivalent to the Lua code: 1441equivalent to the Lua code:
1432\begin{verbatim} 1442\begin{verbatim}
1433 a = f(t.x, 4) 1443 a = f("how", t.x, 4)
1434\end{verbatim} 1444\end{verbatim}
1435\begin{verbatim} 1445\begin{verbatim}
1446 lua_pushstring("how"); /* 1st argument */
1436 lua_pushobject(lua_getglobal("t")); /* push value of global 't' */ 1447 lua_pushobject(lua_getglobal("t")); /* push value of global 't' */
1437 lua_pushstring("x"); /* push the string 'x' */ 1448 lua_pushstring("x"); /* push the string 'x' */
1438 lua_pushobject(lua_gettable()); /* push result of t.x (= t['x']) */ 1449 lua_pushobject(lua_gettable()); /* push result of t.x (= t['x']) */
1439 lua_pushnumber(4); /* 2nd argument */ 1450 lua_pushnumber(4); /* 3th argument */
1440 lua_callfunction(lua_getglobal("f")); /* call Lua function */ 1451 lua_callfunction(lua_getglobal("f")); /* call Lua function */
1441 lua_pushobject(lua_getresult(1)); /* push first result of the call */ 1452 lua_pushobject(lua_getresult(1)); /* push first result of the call */
1442 lua_setglobal("a"); /* sets global variable 'a' */ 1453 lua_setglobal("a"); /* sets global variable 'a' */
@@ -1928,8 +1939,8 @@ See some examples below:
1928 --> x="apple and orange and lime" 1939 --> x="apple and orange and lime"
1929 1940
1930 t = {} 1941 t = {}
1931 gsub("first second word", "(%w%w*)", rawsettable, t) 1942 dummy, t.n = gsub("first second word", "(%w%w*)", rawsettable, t)
1932 --> t={"first", "second", "word"} 1943 --> t={"first", "second", "word"; n=3}
1933\end{verbatim} 1944\end{verbatim}
1934 1945
1935 1946
@@ -2443,13 +2454,34 @@ the previous public versions of Lua,
2443some differences had to be introduced. 2454some differences had to be introduced.
2444Here is a list of all these incompatibilities. 2455Here is a list of all these incompatibilities.
2445 2456
2457\subsection*{Incompatibilities with \Index{version 2.5}}
2458\begin{itemize}
2459\item
2460The whole fallback mechanism has been replaced by tag methods.
2461Nevertheless, the function \verb|setfallback| has been rewritten in
2462a way that uses tag methods to fully emulate the old behavior
2463of fallbacks.
2464\item
2465Tags now must be created with the function \verb|newtag|.
2466Nevertheless, old user defined tags are still accepted
2467(user defined tags must be positive;
2468\verb|newtag| uses negative numbers).
2469Tag methods cannot be set for such user defined tags,
2470and fallbacks do not affect tags created by \verb|newtag|.
2471\item
2472Lua 2.5 accepts mixed comparisons of strings and numbers,
2473like \verb|2<"12"|, giving weird results.
2474Now this is an error.
2475\item
2476Character \verb|"-"| (hyphen) now is ``magic'' in pattern matching.
2477\item
2478Some API functions have been rewritten as macros.
2479\end{itemize}
2480
2446\subsection*{Incompatibilities with \Index{version 2.4}} 2481\subsection*{Incompatibilities with \Index{version 2.4}}
2447The whole I/O facilities have been rewritten. 2482The whole I/O facilities have been rewritten.
2448We strongly encourage programmers to adapt their code 2483We strongly encourage programmers to adapt their code
2449to this new version. 2484to this new version.
2450However, we are keeping the old version of the libraries
2451in the distribution,
2452to allow a smooth transition.
2453The incompatibilities between the new and the old libraries are: 2485The incompatibilities between the new and the old libraries are:
2454\begin{itemize} 2486\begin{itemize}
2455\item The format facility of function \verb|write| has been supersed by 2487\item The format facility of function \verb|write| has been supersed by
@@ -2550,7 +2582,3 @@ Special care should be taken with macros like
2550\end{document} 2582\end{document}
2551 2583
2552 2584
2553
2554
2555
2556