aboutsummaryrefslogtreecommitdiff
path: root/manual/manual.of
diff options
context:
space:
mode:
Diffstat (limited to 'manual/manual.of')
-rw-r--r--manual/manual.of139
1 files changed, 9 insertions, 130 deletions
diff --git a/manual/manual.of b/manual/manual.of
index 6d19e251..73d25951 100644
--- a/manual/manual.of
+++ b/manual/manual.of
@@ -1467,7 +1467,7 @@ It has the following syntax:
1467 exp @bnfter{,} exp @bnfopt{@bnfter{,} exp} @Rw{do} block @Rw{end}} 1467 exp @bnfter{,} exp @bnfopt{@bnfter{,} exp} @Rw{do} block @Rw{end}}
1468} 1468}
1469The given identifier (@bnfNter{Name}) defines the control variable, 1469The given identifier (@bnfNter{Name}) defines the control variable,
1470which is a new variable local to the loop body (@emph{block}). 1470which is a new read-only variable local to the loop body (@emph{block}).
1471 1471
1472The loop starts by evaluating once the three control expressions. 1472The loop starts by evaluating once the three control expressions.
1473Their values are called respectively 1473Their values are called respectively
@@ -1499,11 +1499,6 @@ For integer loops,
1499the control variable never wraps around; 1499the control variable never wraps around;
1500instead, the loop ends in case of an overflow. 1500instead, the loop ends in case of an overflow.
1501 1501
1502You should not change the value of the control variable
1503during the loop.
1504If you need its value after the loop,
1505assign it to another variable before exiting the loop.
1506
1507} 1502}
1508 1503
1509@sect4{@title{The generic @Rw{for} loop} 1504@sect4{@title{The generic @Rw{for} loop}
@@ -1526,7 +1521,8 @@ for @rep{var_1}, @Cdots, @rep{var_n} in @rep{explist} do @rep{body} end
1526works as follows. 1521works as follows.
1527 1522
1528The names @rep{var_i} declare loop variables local to the loop body. 1523The names @rep{var_i} declare loop variables local to the loop body.
1529The first of these variables is the @emph{control variable}. 1524The first of these variables is the @emph{control variable},
1525which is a read-only variable.
1530 1526
1531The loop starts by evaluating @rep{explist} 1527The loop starts by evaluating @rep{explist}
1532to produce four values: 1528to produce four values:
@@ -1550,9 +1546,6 @@ to-be-closed variable @see{to-be-closed},
1550which can be used to release resources when the loop ends. 1546which can be used to release resources when the loop ends.
1551Otherwise, it does not interfere with the loop. 1547Otherwise, it does not interfere with the loop.
1552 1548
1553You should not change the value of the control variable
1554during the loop.
1555
1556} 1549}
1557 1550
1558} 1551}
@@ -1586,7 +1579,8 @@ Each variable name may be postfixed by an attribute
1586@producname{attrib}@producbody{@bnfopt{@bnfter{<} @bnfNter{Name} @bnfter{>}}} 1579@producname{attrib}@producbody{@bnfopt{@bnfter{<} @bnfNter{Name} @bnfter{>}}}
1587} 1580}
1588There are two possible attributes: 1581There are two possible attributes:
1589@id{const}, which declares a @x{constant variable}, 1582@id{const}, which declares a @emph{constant} or @emph{read-only} variable,
1583@index{constant variable}
1590that is, a variable that cannot be assigned to 1584that is, a variable that cannot be assigned to
1591after its initialization; 1585after its initialization;
1592and @id{close}, which declares a to-be-closed variable @see{to-be-closed}. 1586and @id{close}, which declares a to-be-closed variable @see{to-be-closed}.
@@ -9118,7 +9112,7 @@ is a more portable solution.
9118@simplesect{ 9112@simplesect{
9119 9113
9120Here we list the incompatibilities that you may find when moving a program 9114Here we list the incompatibilities that you may find when moving a program
9121from @N{Lua 5.3} to @N{Lua 5.4}. 9115from @N{Lua 5.4} to @N{Lua 5.5}.
9122 9116
9123You can avoid some incompatibilities by compiling Lua with 9117You can avoid some incompatibilities by compiling Lua with
9124appropriate options (see file @id{luaconf.h}). 9118appropriate options (see file @id{luaconf.h}).
@@ -9155,51 +9149,9 @@ change between versions.
9155@itemize{ 9149@itemize{
9156 9150
9157@item{ 9151@item{
9158The coercion of strings to numbers in 9152The control variable in @Rw{for} loops are read only.
9159arithmetic and bitwise operations 9153If you need to change it,
9160has been removed from the core language. 9154declare a local variable with the same name in the loop body.
9161The string library does a similar job
9162for arithmetic (but not for bitwise) operations
9163using the string metamethods.
9164However, unlike in previous versions,
9165the new implementation preserves the implicit type of the numeral
9166in the string.
9167For instance, the result of @T{"1" + "2"} now is an integer,
9168not a float.
9169}
9170
9171@item{
9172Literal decimal integer constants that overflow are read as floats,
9173instead of wrapping around.
9174You can use hexadecimal notation for such constants if you
9175want the old behavior
9176(reading them as integers with wrap around).
9177}
9178
9179@item{
9180The use of the @idx{__lt} metamethod to emulate @idx{__le}
9181has been removed.
9182When needed, this metamethod must be explicitly defined.
9183}
9184
9185@item{
9186The semantics of the numerical @Rw{for} loop
9187over integers changed in some details.
9188In particular, the control variable never wraps around.
9189}
9190
9191@item{
9192A label for a @Rw{goto} cannot be declared where a label with the same
9193name is visible, even if this other label is declared in an enclosing
9194block.
9195}
9196
9197@item{
9198When finalizing an object,
9199Lua does not ignore @idx{__gc} metamethods that are not functions.
9200Any value will be called, if present.
9201(Non-callable values will generate a warning,
9202like any other error when calling a finalizer.)
9203} 9155}
9204 9156
9205} 9157}
@@ -9210,39 +9162,6 @@ like any other error when calling a finalizer.)
9210@itemize{ 9162@itemize{
9211 9163
9212@item{ 9164@item{
9213The function @Lid{print} does not call @Lid{tostring}
9214to format its arguments;
9215instead, it has this functionality hardwired.
9216You should use @idx{__tostring} to modify how values are printed.
9217}
9218
9219@item{
9220The pseudo-random number generator used by the function @Lid{math.random}
9221now starts with a somewhat random seed.
9222Moreover, it uses a different algorithm.
9223}
9224
9225@item{
9226By default, the decoding functions in the @Lid{utf8} library
9227do not accept surrogates as valid code points.
9228An extra parameter in these functions makes them more permissive.
9229}
9230
9231@item{
9232The options @St{setpause} and @St{setstepmul}
9233of the function @Lid{collectgarbage} are deprecated.
9234You should use the new option @St{incremental} to set them.
9235}
9236
9237@item{
9238The function @Lid{io.lines} now returns four values,
9239instead of just one.
9240That can be a problem when it is used as the sole
9241argument to another function that has optional parameters,
9242such as in @T{load(io.lines(filename, "L"))}.
9243To fix that issue,
9244you can wrap the call into parentheses,
9245to adjust its number of results to one.
9246} 9165}
9247 9166
9248} 9167}
@@ -9254,46 +9173,6 @@ to adjust its number of results to one.
9254@itemize{ 9173@itemize{
9255 9174
9256@item{ 9175@item{
9257Full userdata now has an arbitrary number of associated user values.
9258Therefore, the functions @id{lua_newuserdata},
9259@id{lua_setuservalue}, and @id{lua_getuservalue} were
9260replaced by @Lid{lua_newuserdatauv},
9261@Lid{lua_setiuservalue}, and @Lid{lua_getiuservalue},
9262which have an extra argument.
9263
9264For compatibility, the old names still work as macros assuming
9265one single user value.
9266Note, however, that userdata with zero user values
9267are more efficient memory-wise.
9268}
9269
9270@item{
9271The function @Lid{lua_resume} has an extra parameter.
9272This out parameter returns the number of values on
9273the top of the stack that were yielded or returned by the coroutine.
9274(In previous versions,
9275those values were the entire stack.)
9276}
9277
9278@item{
9279The function @Lid{lua_version} returns the version number,
9280instead of an address of the version number.
9281The Lua core should work correctly with libraries using their
9282own static copies of the same core,
9283so there is no need to check whether they are using the same
9284address space.
9285}
9286
9287@item{
9288The constant @id{LUA_ERRGCMM} was removed.
9289Errors in finalizers are never propagated;
9290instead, they generate a warning.
9291}
9292
9293@item{
9294The options @idx{LUA_GCSETPAUSE} and @idx{LUA_GCSETSTEPMUL}
9295of the function @Lid{lua_gc} are deprecated.
9296You should use the new option @id{LUA_GCINC} to set them.
9297} 9176}
9298 9177
9299} 9178}