Skip to content

Commit 87a9573

Browse files
committed
Documentation
Better explanation about the guaranties of multiple assignment in the manual.
1 parent deac067 commit 87a9573

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

ldebug.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static int getbaseline (const Proto *f, int pc, int *basepc) {
6464
}
6565
else {
6666
int i = cast_uint(pc) / MAXIWTHABS - 1; /* get an estimate */
67-
/* estimate must be a lower bond of the correct base */
67+
/* estimate must be a lower bound of the correct base */
6868
lua_assert(i < 0 ||
6969
(i < f->sizeabslineinfo && f->abslineinfo[i].pc <= pc));
7070
while (i + 1 < f->sizeabslineinfo && pc >= f->abslineinfo[i + 1].pc)

lstrlib.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ static const char *get2digits (const char *s) {
12171217

12181218

12191219
/*
1220-
** Chech whether a conversion specification is valid. When called,
1220+
** Check whether a conversion specification is valid. When called,
12211221
** first character in 'form' must be '%' and last character must
12221222
** be a valid conversion specifier. 'flags' are the accepted flags;
12231223
** 'precision' signals whether to accept a precision.

lvm.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ void luaV_finishOp (lua_State *L) {
11091109
#define ProtectNT(exp) (savepc(L), (exp), updatetrap(ci))
11101110

11111111
/*
1112-
** Protect code that can only raise errors. (That is, it cannnot change
1112+
** Protect code that can only raise errors. (That is, it cannot change
11131113
** the stack or hooks.)
11141114
*/
11151115
#define halfProtect(exp) (savestate(L,ci), (exp))

manual/manual.of

+10-2
Original file line numberDiff line numberDiff line change
@@ -1346,8 +1346,10 @@ then all values returned by that call enter the list of values,
13461346
before the adjustment
13471347
(except when the call is enclosed in parentheses; see @See{expressions}).
13481348

1349-
The assignment statement first evaluates all its expressions
1350-
and only then the assignments are performed.
1349+
If a variable is both assigned and read
1350+
inside a multiple assignment,
1351+
Lua ensures all reads get the value of the variable
1352+
before the assignment.
13511353
Thus the code
13521354
@verbatim{
13531355
i = 3
@@ -1367,6 +1369,12 @@ x, y, z = y, z, x
13671369
}
13681370
cyclically permutes the values of @id{x}, @id{y}, and @id{z}.
13691371

1372+
Note that this guarantee covers only accesses
1373+
syntactically inside the assignment statement.
1374+
If a function or a metamethod called during the assignment
1375+
changes the value of a variable,
1376+
Lua gives no guarantees about the order of that access.
1377+
13701378
An assignment to a global name @T{x = val}
13711379
is equivalent to the assignment
13721380
@T{_ENV.x = val} @see{globalenv}.

0 commit comments

Comments
 (0)