diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-11-29 16:02:44 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-11-29 16:02:44 -0200 |
commit | 6d04537ea660fd12fc16c328366b701fabaf4919 (patch) | |
tree | 41eab6e4d87552e29731db552f7d58d679c56973 /manual | |
parent | 7696c6474fe51ed59fee324e78c1233af74febdd (diff) | |
download | lua-6d04537ea660fd12fc16c328366b701fabaf4919.tar.gz lua-6d04537ea660fd12fc16c328366b701fabaf4919.tar.bz2 lua-6d04537ea660fd12fc16c328366b701fabaf4919.zip |
A to-be-closed variable must have a closable value (or be nil)
It is an error for a to-be-closed variable to have a non-closable
non-nil value when it is being closed. This situation does not seem to
be useful and often hints to an error. (Particularly in the C API, it is
easy to change a to-be-closed index by mistake.)
Diffstat (limited to 'manual')
-rw-r--r-- | manual/manual.of | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/manual/manual.of b/manual/manual.of index f891c33e..3902f2f3 100644 --- a/manual/manual.of +++ b/manual/manual.of | |||
@@ -1063,11 +1063,16 @@ which start with @T{0x} or @T{0X}. | |||
1063 | Hexadecimal constants also accept an optional fractional part | 1063 | Hexadecimal constants also accept an optional fractional part |
1064 | plus an optional binary exponent, | 1064 | plus an optional binary exponent, |
1065 | marked by a letter @Char{p} or @Char{P}. | 1065 | marked by a letter @Char{p} or @Char{P}. |
1066 | |||
1066 | A numeric constant with a radix point or an exponent | 1067 | A numeric constant with a radix point or an exponent |
1067 | denotes a float; | 1068 | denotes a float; |
1068 | otherwise, | 1069 | otherwise, |
1069 | if its value fits in an integer, | 1070 | if its value fits in an integer or it is a hexadecimal constant, |
1070 | it denotes an integer. | 1071 | it denotes an integer; |
1072 | otherwise (that is, a decimal integer numeral that overflows), | ||
1073 | it denotes a float. | ||
1074 | (Hexadecimal integer numerals that overflow @emph{wrap around}; | ||
1075 | they always denote an integer value.) | ||
1071 | Examples of valid integer constants are | 1076 | Examples of valid integer constants are |
1072 | @verbatim{ | 1077 | @verbatim{ |
1073 | 3 345 0xff 0xBEBADA | 1078 | 3 345 0xff 0xBEBADA |
@@ -1542,7 +1547,8 @@ If the value of the variable when it goes out of scope is a function, | |||
1542 | that function is called; | 1547 | that function is called; |
1543 | otherwise, if the value has a @idx{__close} metamethod, | 1548 | otherwise, if the value has a @idx{__close} metamethod, |
1544 | that metamethod is called; | 1549 | that metamethod is called; |
1545 | otherwise, nothing is done. | 1550 | otherwise, if the value is @nil, nothing is done; |
1551 | otherwise, an error is raised. | ||
1546 | In the function case, | 1552 | In the function case, |
1547 | if the scope is being closed by an error, | 1553 | if the scope is being closed by an error, |
1548 | the error object is passed as an argument to the function; | 1554 | the error object is passed as an argument to the function; |
@@ -1665,7 +1671,7 @@ If both operands are integers, | |||
1665 | the operation is performed over integers and the result is an integer. | 1671 | the operation is performed over integers and the result is an integer. |
1666 | Otherwise, if both operands are numbers, | 1672 | Otherwise, if both operands are numbers, |
1667 | then they are converted to floats, | 1673 | then they are converted to floats, |
1668 | the operation is performed following the usual rules | 1674 | the operation is performed following the machine's rules |
1669 | for floating-point arithmetic | 1675 | for floating-point arithmetic |
1670 | (usually the @x{IEEE 754} standard), | 1676 | (usually the @x{IEEE 754} standard), |
1671 | and the result is a float. | 1677 | and the result is a float. |
@@ -4998,7 +5004,7 @@ This call leaves the final string on the top of the stack. | |||
4998 | 5004 | ||
4999 | } | 5005 | } |
5000 | 5006 | ||
5001 | If you know beforehand the total size of the resulting string, | 5007 | If you know beforehand the maximum size of the resulting string, |
5002 | you can use the buffer like this: | 5008 | you can use the buffer like this: |
5003 | @itemize{ | 5009 | @itemize{ |
5004 | 5010 | ||
@@ -5012,7 +5018,8 @@ size @id{sz} with a call @T{luaL_buffinitsize(L, &b, sz)}.} | |||
5012 | @item{ | 5018 | @item{ |
5013 | Finish by calling @T{luaL_pushresultsize(&b, sz)}, | 5019 | Finish by calling @T{luaL_pushresultsize(&b, sz)}, |
5014 | where @id{sz} is the total size of the resulting string | 5020 | where @id{sz} is the total size of the resulting string |
5015 | copied into that space. | 5021 | copied into that space (which may be smaller than or |
5022 | equal to the preallocated size). | ||
5016 | } | 5023 | } |
5017 | 5024 | ||
5018 | } | 5025 | } |
@@ -5028,8 +5035,8 @@ when you call a buffer operation, | |||
5028 | the stack is at the same level | 5035 | the stack is at the same level |
5029 | it was immediately after the previous buffer operation. | 5036 | it was immediately after the previous buffer operation. |
5030 | (The only exception to this rule is @Lid{luaL_addvalue}.) | 5037 | (The only exception to this rule is @Lid{luaL_addvalue}.) |
5031 | After calling @Lid{luaL_pushresult} the stack is back to its | 5038 | After calling @Lid{luaL_pushresult}, |
5032 | level when the buffer was initialized, | 5039 | the stack is back to its level when the buffer was initialized, |
5033 | plus the final string on its top. | 5040 | plus the final string on its top. |
5034 | 5041 | ||
5035 | } | 5042 | } |
@@ -7118,7 +7125,7 @@ empty string as a match immediately after another match. | |||
7118 | As an example, | 7125 | As an example, |
7119 | consider the results of the following code: | 7126 | consider the results of the following code: |
7120 | @verbatim{ | 7127 | @verbatim{ |
7121 | > string.gsub("abc", "()a*()", print) | 7128 | > string.gsub("abc", "()a*()", print); |
7122 | --> 1 2 | 7129 | --> 1 2 |
7123 | --> 3 3 | 7130 | --> 3 3 |
7124 | --> 4 4 | 7131 | --> 4 4 |