aboutsummaryrefslogtreecommitdiff
path: root/manual
diff options
context:
space:
mode:
Diffstat (limited to 'manual')
-rw-r--r--manual/manual.of162
1 files changed, 27 insertions, 135 deletions
diff --git a/manual/manual.of b/manual/manual.of
index f8d8ddd4..1e219f9a 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}.
@@ -3671,7 +3665,8 @@ Other upvalues are initialized with @nil.
3671 3665
3672} 3666}
3673 3667
3674@APIEntry{lua_State *lua_newstate (lua_Alloc f, void *ud);| 3668@APIEntry{lua_State *lua_newstate (lua_Alloc f, void *ud,
3669 unsigned int seed);|
3675@apii{0,0,-} 3670@apii{0,0,-}
3676 3671
3677Creates a new independent state and returns its main thread. 3672Creates a new independent state and returns its main thread.
@@ -3682,6 +3677,8 @@ Lua will do all memory allocation for this state
3682through this function @seeF{lua_Alloc}. 3677through this function @seeF{lua_Alloc}.
3683The second argument, @id{ud}, is an opaque pointer that Lua 3678The second argument, @id{ud}, is an opaque pointer that Lua
3684passes to the allocator in every call. 3679passes to the allocator in every call.
3680The third argument, @id{seed}, is a seed for the hashing of
3681strings when they are used as table keys.
3685 3682
3686} 3683}
3687 3684
@@ -5737,6 +5734,16 @@ it does not run it.
5737 5734
5738} 5735}
5739 5736
5737@APIEntry{unsigned int luaL_makeseed (lua_State *L);|
5738@apii{0,0,-}
5739
5740Returns a value with a weak attempt for randomness.
5741(It produces that value based on the current date and time
5742and the address of an internal variable,
5743in case the machine has Address Space Layout Randomization.)
5744
5745}
5746
5740 5747
5741@APIEntry{void luaL_newlib (lua_State *L, const luaL_Reg l[]);| 5748@APIEntry{void luaL_newlib (lua_State *L, const luaL_Reg l[]);|
5742@apii{0,1,m} 5749@apii{0,1,m}
@@ -6909,9 +6916,9 @@ including if necessary a path and an extension.
6909(which may depend on the @N{C compiler} and linker used). 6916(which may depend on the @N{C compiler} and linker used).
6910 6917
6911This functionality is not supported by @N{ISO C}. 6918This functionality is not supported by @N{ISO C}.
6912As such, it is only available on some platforms 6919As such, @id{loadlib} is only available on some platforms:
6913(Windows, Linux, Mac OS X, Solaris, BSD, 6920Linux, Windows, Mac OS X, Solaris, BSD,
6914plus other Unix systems that support the @id{dlfcn} standard). 6921plus other Unix systems that support the @id{dlfcn} standard.
6915 6922
6916This function is inherently insecure, 6923This function is inherently insecure,
6917as it allows Lua to call any function in any readable dynamic 6924as it allows Lua to call any function in any readable dynamic
@@ -8109,7 +8116,7 @@ different sequences of results each time the program runs.
8109 8116
8110When called with at least one argument, 8117When called with at least one argument,
8111the integer parameters @id{x} and @id{y} are 8118the integer parameters @id{x} and @id{y} are
8112joined into a 128-bit @emphx{seed} that 8119joined into a @emphx{seed} that
8113is used to reinitialize the pseudo-random generator; 8120is used to reinitialize the pseudo-random generator;
8114equal seeds produce equal sequences of numbers. 8121equal seeds produce equal sequences of numbers.
8115The default for @id{y} is zero. 8122The default for @id{y} is zero.
@@ -9128,7 +9135,7 @@ is a more portable solution.
9128@simplesect{ 9135@simplesect{
9129 9136
9130Here we list the incompatibilities that you may find when moving a program 9137Here we list the incompatibilities that you may find when moving a program
9131from @N{Lua 5.3} to @N{Lua 5.4}. 9138from @N{Lua 5.4} to @N{Lua 5.5}.
9132 9139
9133You can avoid some incompatibilities by compiling Lua with 9140You can avoid some incompatibilities by compiling Lua with
9134appropriate options (see file @id{luaconf.h}). 9141appropriate options (see file @id{luaconf.h}).
@@ -9165,51 +9172,9 @@ change between versions.
9165@itemize{ 9172@itemize{
9166 9173
9167@item{ 9174@item{
9168The coercion of strings to numbers in 9175The control variable in @Rw{for} loops are read only.
9169arithmetic and bitwise operations 9176If you need to change it,
9170has been removed from the core language. 9177declare a local variable with the same name in the loop body.
9171The string library does a similar job
9172for arithmetic (but not for bitwise) operations
9173using the string metamethods.
9174However, unlike in previous versions,
9175the new implementation preserves the implicit type of the numeral
9176in the string.
9177For instance, the result of @T{"1" + "2"} now is an integer,
9178not a float.
9179}
9180
9181@item{
9182Literal decimal integer constants that overflow are read as floats,
9183instead of wrapping around.
9184You can use hexadecimal notation for such constants if you
9185want the old behavior
9186(reading them as integers with wrap around).
9187}
9188
9189@item{
9190The use of the @idx{__lt} metamethod to emulate @idx{__le}
9191has been removed.
9192When needed, this metamethod must be explicitly defined.
9193}
9194
9195@item{
9196The semantics of the numerical @Rw{for} loop
9197over integers changed in some details.
9198In particular, the control variable never wraps around.
9199}
9200
9201@item{
9202A label for a @Rw{goto} cannot be declared where a label with the same
9203name is visible, even if this other label is declared in an enclosing
9204block.
9205}
9206
9207@item{
9208When finalizing an object,
9209Lua does not ignore @idx{__gc} metamethods that are not functions.
9210Any value will be called, if present.
9211(Non-callable values will generate a warning,
9212like any other error when calling a finalizer.)
9213} 9178}
9214 9179
9215} 9180}
@@ -9220,39 +9185,6 @@ like any other error when calling a finalizer.)
9220@itemize{ 9185@itemize{
9221 9186
9222@item{ 9187@item{
9223The function @Lid{print} does not call @Lid{tostring}
9224to format its arguments;
9225instead, it has this functionality hardwired.
9226You should use @idx{__tostring} to modify how values are printed.
9227}
9228
9229@item{
9230The pseudo-random number generator used by the function @Lid{math.random}
9231now starts with a somewhat random seed.
9232Moreover, it uses a different algorithm.
9233}
9234
9235@item{
9236By default, the decoding functions in the @Lid{utf8} library
9237do not accept surrogates as valid code points.
9238An extra parameter in these functions makes them more permissive.
9239}
9240
9241@item{
9242The options @St{setpause} and @St{setstepmul}
9243of the function @Lid{collectgarbage} are deprecated.
9244You should use the new option @St{incremental} to set them.
9245}
9246
9247@item{
9248The function @Lid{io.lines} now returns four values,
9249instead of just one.
9250That can be a problem when it is used as the sole
9251argument to another function that has optional parameters,
9252such as in @T{load(io.lines(filename, "L"))}.
9253To fix that issue,
9254you can wrap the call into parentheses,
9255to adjust its number of results to one.
9256} 9188}
9257 9189
9258} 9190}
@@ -9264,46 +9196,6 @@ to adjust its number of results to one.
9264@itemize{ 9196@itemize{
9265 9197
9266@item{ 9198@item{
9267Full userdata now has an arbitrary number of associated user values.
9268Therefore, the functions @id{lua_newuserdata},
9269@id{lua_setuservalue}, and @id{lua_getuservalue} were
9270replaced by @Lid{lua_newuserdatauv},
9271@Lid{lua_setiuservalue}, and @Lid{lua_getiuservalue},
9272which have an extra argument.
9273
9274For compatibility, the old names still work as macros assuming
9275one single user value.
9276Note, however, that userdata with zero user values
9277are more efficient memory-wise.
9278}
9279
9280@item{
9281The function @Lid{lua_resume} has an extra parameter.
9282This out parameter returns the number of values on
9283the top of the stack that were yielded or returned by the coroutine.
9284(In previous versions,
9285those values were the entire stack.)
9286}
9287
9288@item{
9289The function @Lid{lua_version} returns the version number,
9290instead of an address of the version number.
9291The Lua core should work correctly with libraries using their
9292own static copies of the same core,
9293so there is no need to check whether they are using the same
9294address space.
9295}
9296
9297@item{
9298The constant @id{LUA_ERRGCMM} was removed.
9299Errors in finalizers are never propagated;
9300instead, they generate a warning.
9301}
9302
9303@item{
9304The options @idx{LUA_GCSETPAUSE} and @idx{LUA_GCSETSTEPMUL}
9305of the function @Lid{lua_gc} are deprecated.
9306You should use the new option @id{LUA_GCINC} to set them.
9307} 9199}
9308 9200
9309} 9201}