diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-03-13 13:16:53 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-03-13 13:16:53 -0300 |
commit | cf71a5ddc742692fad813f89f1c9ef53e1ffde0f (patch) | |
tree | df02305ff3cf05908f21829384e3a7f8699d2331 /manual | |
parent | 2c32bff60987d38a60a58d4f0123f3783da60a63 (diff) | |
download | lua-cf71a5ddc742692fad813f89f1c9ef53e1ffde0f.tar.gz lua-cf71a5ddc742692fad813f89f1c9ef53e1ffde0f.tar.bz2 lua-cf71a5ddc742692fad813f89f1c9ef53e1ffde0f.zip |
Details
Several small improvements (code style, warnings, comments, more tests),
in particular:
- 'lua_topointer' extended to handle strings
- raises an error in 'string.format("%10q")' ('%q' with modifiers)
- in the manual for 'string.format', the term "option" replaced by
"conversion specifier" (the term used by the C standard)
Diffstat (limited to 'manual')
-rw-r--r-- | manual/manual.of | 54 |
1 files changed, 32 insertions, 22 deletions
diff --git a/manual/manual.of b/manual/manual.of index 421d04de..9c8ab033 100644 --- a/manual/manual.of +++ b/manual/manual.of | |||
@@ -143,7 +143,7 @@ that is, @x{arrays} that can have as indices not only numbers, | |||
143 | but any Lua value except @nil and @x{NaN}. | 143 | but any Lua value except @nil and @x{NaN}. |
144 | (@emphx{Not a Number} is a special floating-point value | 144 | (@emphx{Not a Number} is a special floating-point value |
145 | used by the @x{IEEE 754} standard to represent | 145 | used by the @x{IEEE 754} standard to represent |
146 | undefined or unrepresentable numerical results, such as @T{0/0}.) | 146 | undefined numerical results, such as @T{0/0}.) |
147 | Tables can be @emph{heterogeneous}; | 147 | Tables can be @emph{heterogeneous}; |
148 | that is, they can contain values of all types (except @nil). | 148 | that is, they can contain values of all types (except @nil). |
149 | Any key with value @nil is not considered part of the table. | 149 | Any key with value @nil is not considered part of the table. |
@@ -670,8 +670,8 @@ are called when the garbage collector detects that the | |||
670 | corresponding table or userdata is unreachable. | 670 | corresponding table or userdata is unreachable. |
671 | Finalizers allow you to coordinate Lua's garbage collection | 671 | Finalizers allow you to coordinate Lua's garbage collection |
672 | with external resource management | 672 | with external resource management |
673 | (such as closing files, network or database connections, | 673 | such as closing files, network or database connections, |
674 | or freeing your own memory). | 674 | or freeing your own memory. |
675 | 675 | ||
676 | For an object (table or userdata) to be finalized when collected, | 676 | For an object (table or userdata) to be finalized when collected, |
677 | you must @emph{mark} it for finalization. | 677 | you must @emph{mark} it for finalization. |
@@ -1323,11 +1323,12 @@ labels in Lua are considered statements too: | |||
1323 | } | 1323 | } |
1324 | 1324 | ||
1325 | A label is visible in the entire block where it is defined, | 1325 | A label is visible in the entire block where it is defined, |
1326 | except | 1326 | except inside nested functions. |
1327 | inside nested blocks where a label with the same name is defined and | ||
1328 | inside nested functions. | ||
1329 | A goto may jump to any visible label as long as it does not | 1327 | A goto may jump to any visible label as long as it does not |
1330 | enter into the scope of a local variable. | 1328 | enter into the scope of a local variable. |
1329 | A label should not be declared | ||
1330 | where a label with the same name is visible, | ||
1331 | even if this other label has been declared in an enclosing block. | ||
1331 | 1332 | ||
1332 | Labels and empty statements are called @def{void statements}, | 1333 | Labels and empty statements are called @def{void statements}, |
1333 | as they perform no actions. | 1334 | as they perform no actions. |
@@ -1537,7 +1538,7 @@ goes out of scope, including normal block termination, | |||
1537 | exiting its block by @Rw{break}/@Rw{goto}/@Rw{return}, | 1538 | exiting its block by @Rw{break}/@Rw{goto}/@Rw{return}, |
1538 | or exiting by an error. | 1539 | or exiting by an error. |
1539 | 1540 | ||
1540 | Here, to \emph{close} a value means | 1541 | Here, to @emph{close} a value means |
1541 | to call its @idx{__close} metamethod. | 1542 | to call its @idx{__close} metamethod. |
1542 | If the value is @nil, it is ignored; | 1543 | If the value is @nil, it is ignored; |
1543 | otherwise, | 1544 | otherwise, |
@@ -4236,7 +4237,7 @@ indicates whether the operation succeeded. | |||
4236 | 4237 | ||
4237 | Converts the value at the given index to a generic | 4238 | Converts the value at the given index to a generic |
4238 | @N{C pointer} (@T{void*}). | 4239 | @N{C pointer} (@T{void*}). |
4239 | The value can be a userdata, a table, a thread, or a function; | 4240 | The value can be a userdata, a table, a thread, a string, or a function; |
4240 | otherwise, @id{lua_topointer} returns @id{NULL}. | 4241 | otherwise, @id{lua_topointer} returns @id{NULL}. |
4241 | Different objects will give different pointers. | 4242 | Different objects will give different pointers. |
4242 | There is no way to convert the pointer back to its original value. | 4243 | There is no way to convert the pointer back to its original value. |
@@ -6712,8 +6713,10 @@ to save space. | |||
6712 | 6713 | ||
6713 | Functions with upvalues have only their number of upvalues saved. | 6714 | Functions with upvalues have only their number of upvalues saved. |
6714 | When (re)loaded, | 6715 | When (re)loaded, |
6715 | those upvalues receive fresh instances containing @nil. | 6716 | those upvalues receive fresh instances. |
6716 | (You can use the debug library to serialize | 6717 | (See the @Lid{load} function for details about |
6718 | how these upvalues are initialized. | ||
6719 | You can use the debug library to serialize | ||
6717 | and reload the upvalues of a function | 6720 | and reload the upvalues of a function |
6718 | in a way adequate to your needs.) | 6721 | in a way adequate to your needs.) |
6719 | 6722 | ||
@@ -6747,12 +6750,12 @@ after the two indices. | |||
6747 | Returns a formatted version of its variable number of arguments | 6750 | Returns a formatted version of its variable number of arguments |
6748 | following the description given in its first argument (which must be a string). | 6751 | following the description given in its first argument (which must be a string). |
6749 | The format string follows the same rules as the @ANSI{sprintf}. | 6752 | The format string follows the same rules as the @ANSI{sprintf}. |
6750 | The only differences are that the options/modifiers | 6753 | The only differences are that the conversion specifiers and modifiers |
6751 | @T{*}, @id{h}, @id{L}, @id{l}, @id{n}, | 6754 | @T{*}, @id{h}, @id{L}, @id{l}, @id{n}, |
6752 | and @id{p} are not supported | 6755 | and @id{p} are not supported |
6753 | and that there is an extra option, @id{q}. | 6756 | and that there is an extra specifier, @id{q}. |
6754 | 6757 | ||
6755 | The @id{q} option formats booleans, nil, numbers, and strings | 6758 | The specifier @id{q} formats booleans, nil, numbers, and strings |
6756 | in a way that the result is a valid constant in Lua source code. | 6759 | in a way that the result is a valid constant in Lua source code. |
6757 | Booleans and nil are written in the obvious way | 6760 | Booleans and nil are written in the obvious way |
6758 | (@id{true}, @id{false}, @id{nil}). | 6761 | (@id{true}, @id{false}, @id{nil}). |
@@ -6770,22 +6773,23 @@ may produce the string: | |||
6770 | "a string with \"quotes\" and \ | 6773 | "a string with \"quotes\" and \ |
6771 | new line" | 6774 | new line" |
6772 | } | 6775 | } |
6776 | This specifier does not support modifiers (flags, width, length). | ||
6773 | 6777 | ||
6774 | Options | 6778 | The conversion specifiers |
6775 | @id{A}, @id{a}, @id{E}, @id{e}, @id{f}, | 6779 | @id{A}, @id{a}, @id{E}, @id{e}, @id{f}, |
6776 | @id{G}, and @id{g} all expect a number as argument. | 6780 | @id{G}, and @id{g} all expect a number as argument. |
6777 | Options @id{c}, @id{d}, | 6781 | The specifiers @id{c}, @id{d}, |
6778 | @id{i}, @id{o}, @id{u}, @id{X}, and @id{x} | 6782 | @id{i}, @id{o}, @id{u}, @id{X}, and @id{x} |
6779 | expect an integer. | 6783 | expect an integer. |
6780 | When Lua is compiled with a C89 compiler, | 6784 | When Lua is compiled with a C89 compiler, |
6781 | options @id{A} and @id{a} (hexadecimal floats) | 6785 | the specifiers @id{A} and @id{a} (hexadecimal floats) |
6782 | do not support any modifier (flags, width, length). | 6786 | do not support modifiers. |
6783 | 6787 | ||
6784 | Option @id{s} expects a string; | 6788 | The specifier @id{s} expects a string; |
6785 | if its argument is not a string, | 6789 | if its argument is not a string, |
6786 | it is converted to one following the same rules of @Lid{tostring}. | 6790 | it is converted to one following the same rules of @Lid{tostring}. |
6787 | If the option has any modifier (flags, width, length), | 6791 | If the specifier has any modifier, |
6788 | the string argument should not contain @x{embedded zeros}. | 6792 | the corresponding string argument should not contain @x{embedded zeros}. |
6789 | 6793 | ||
6790 | } | 6794 | } |
6791 | 6795 | ||
@@ -8009,8 +8013,8 @@ or there is any input from some special files | |||
8009 | } | 8013 | } |
8010 | 8014 | ||
8011 | } | 8015 | } |
8012 | For the last two cases, @id{size} | 8016 | For the last two cases, |
8013 | specifies the size of the buffer, in bytes. | 8017 | @id{size} is a hint for the size of the buffer, in bytes. |
8014 | The default is an appropriate size. | 8018 | The default is an appropriate size. |
8015 | 8019 | ||
8016 | } | 8020 | } |
@@ -8698,6 +8702,12 @@ When a coroutine finishes with an error, | |||
8698 | its stack is unwound (to run any pending closing methods). | 8702 | its stack is unwound (to run any pending closing methods). |
8699 | } | 8703 | } |
8700 | 8704 | ||
8705 | @item{ | ||
8706 | A label for a @Rw{goto} cannot be declared where a label with the same | ||
8707 | name is visible, even if this other label is declared in an enclosing | ||
8708 | block. | ||
8709 | } | ||
8710 | |||
8701 | } | 8711 | } |
8702 | 8712 | ||
8703 | } | 8713 | } |