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