aboutsummaryrefslogtreecommitdiff
path: root/manual
diff options
context:
space:
mode:
Diffstat (limited to 'manual')
-rw-r--r--manual/manual.of17
1 files changed, 8 insertions, 9 deletions
diff --git a/manual/manual.of b/manual/manual.of
index 3902f2f3..8b5e5d93 100644
--- a/manual/manual.of
+++ b/manual/manual.of
@@ -1538,9 +1538,6 @@ except that its value is @emph{closed} whenever the variable
1538goes out of scope, including normal block termination, 1538goes out of scope, including normal block termination,
1539exiting its block by @Rw{break}/@Rw{goto}/@Rw{return}, 1539exiting its block by @Rw{break}/@Rw{goto}/@Rw{return},
1540or exiting by an error. 1540or exiting by an error.
1541If a block ends in a tail call @see{functioncall},
1542all variables of the caller function go out of scope
1543before the start of the callee function.
1544 1541
1545To \emph{close} a value has the following meaning here: 1542To \emph{close} a value has the following meaning here:
1546If the value of the variable when it goes out of scope is a function, 1543If the value of the variable when it goes out of scope is a function,
@@ -2038,8 +2035,8 @@ A call of the form @T{f'@rep{string}'}
2038is syntactic sugar for @T{f('@rep{string}')}; 2035is syntactic sugar for @T{f('@rep{string}')};
2039that is, the argument list is a single literal string. 2036that is, the argument list is a single literal string.
2040 2037
2041A call of the form @T{return @rep{functioncall}} is called 2038A call of the form @T{return @rep{functioncall}} not in the
2042a @def{tail call}. 2039scope of a to-be-closed variable is called a @def{tail call}.
2043Lua implements @def{proper tail calls} 2040Lua implements @def{proper tail calls}
2044(or @emph{proper tail recursion}): 2041(or @emph{proper tail recursion}):
2045in a tail call, 2042in a tail call,
@@ -2049,13 +2046,15 @@ a program can execute.
2049However, a tail call erases any debug information about the 2046However, a tail call erases any debug information about the
2050calling function. 2047calling function.
2051Note that a tail call only happens with a particular syntax, 2048Note that a tail call only happens with a particular syntax,
2052where the @Rw{return} has one single function call as argument; 2049where the @Rw{return} has one single function call as argument,
2053this syntax makes the calling function return exactly 2050and it is outside the scope of any to-be-closed variable.
2054the returns of the called function. 2051This syntax makes the calling function return exactly
2052the returns of the called function,
2053without any intervening action.
2055So, none of the following examples are tail calls: 2054So, none of the following examples are tail calls:
2056@verbatim{ 2055@verbatim{
2057return (f(x)) -- results adjusted to 1 2056return (f(x)) -- results adjusted to 1
2058return 2 * f(x) 2057return 2 * f(x) -- result multiplied by 2
2059return x, f(x) -- additional results 2058return x, f(x) -- additional results
2060f(x); return -- results discarded 2059f(x); return -- results discarded
2061return x or f(x) -- results adjusted to 1 2060return x or f(x) -- results adjusted to 1