aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-10-11 13:49:13 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-10-11 13:49:13 -0300
commit87a9573b2eb3f1da8e438f92ade994160d930b09 (patch)
treea935872e61f23c81b430dd867c98329b8782a907
parentdeac067ed39a44c001599c0d15de09872496b2aa (diff)
downloadlua-87a9573b2eb3f1da8e438f92ade994160d930b09.tar.gz
lua-87a9573b2eb3f1da8e438f92ade994160d930b09.tar.bz2
lua-87a9573b2eb3f1da8e438f92ade994160d930b09.zip
Documentation
Better explanation about the guaranties of multiple assignment in the manual.
-rw-r--r--ldebug.c2
-rw-r--r--lstrlib.c2
-rw-r--r--lvm.c2
-rw-r--r--manual/manual.of12
4 files changed, 13 insertions, 5 deletions
diff --git a/ldebug.c b/ldebug.c
index 433a8759..dde4669e 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -64,7 +64,7 @@ static int getbaseline (const Proto *f, int pc, int *basepc) {
64 } 64 }
65 else { 65 else {
66 int i = cast_uint(pc) / MAXIWTHABS - 1; /* get an estimate */ 66 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 */
68 lua_assert(i < 0 || 68 lua_assert(i < 0 ||
69 (i < f->sizeabslineinfo && f->abslineinfo[i].pc <= pc)); 69 (i < f->sizeabslineinfo && f->abslineinfo[i].pc <= pc));
70 while (i + 1 < f->sizeabslineinfo && pc >= f->abslineinfo[i + 1].pc) 70 while (i + 1 < f->sizeabslineinfo && pc >= f->abslineinfo[i + 1].pc)
diff --git a/lstrlib.c b/lstrlib.c
index e3b8df0f..0b4fdbb7 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1217,7 +1217,7 @@ static const char *get2digits (const char *s) {
1217 1217
1218 1218
1219/* 1219/*
1220** Chech whether a conversion specification is valid. When called, 1220** Check whether a conversion specification is valid. When called,
1221** first character in 'form' must be '%' and last character must 1221** first character in 'form' must be '%' and last character must
1222** be a valid conversion specifier. 'flags' are the accepted flags; 1222** be a valid conversion specifier. 'flags' are the accepted flags;
1223** 'precision' signals whether to accept a precision. 1223** 'precision' signals whether to accept a precision.
diff --git a/lvm.c b/lvm.c
index bdc8e677..49ed3ddf 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1109,7 +1109,7 @@ void luaV_finishOp (lua_State *L) {
1109#define ProtectNT(exp) (savepc(L), (exp), updatetrap(ci)) 1109#define ProtectNT(exp) (savepc(L), (exp), updatetrap(ci))
1110 1110
1111/* 1111/*
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
1113** the stack or hooks.) 1113** the stack or hooks.)
1114*/ 1114*/
1115#define halfProtect(exp) (savestate(L,ci), (exp)) 1115#define halfProtect(exp) (savestate(L,ci), (exp))
diff --git a/manual/manual.of b/manual/manual.of
index ea9a0302..9e0b8835 100644
--- a/manual/manual.of
+++ b/manual/manual.of
@@ -1346,8 +1346,10 @@ then all values returned by that call enter the list of values,
1346before the adjustment 1346before the adjustment
1347(except when the call is enclosed in parentheses; see @See{expressions}). 1347(except when the call is enclosed in parentheses; see @See{expressions}).
1348 1348
1349The assignment statement first evaluates all its expressions 1349If a variable is both assigned and read
1350and only then the assignments are performed. 1350inside a multiple assignment,
1351Lua ensures all reads get the value of the variable
1352before the assignment.
1351Thus the code 1353Thus the code
1352@verbatim{ 1354@verbatim{
1353i = 3 1355i = 3
@@ -1367,6 +1369,12 @@ x, y, z = y, z, x
1367} 1369}
1368cyclically permutes the values of @id{x}, @id{y}, and @id{z}. 1370cyclically permutes the values of @id{x}, @id{y}, and @id{z}.
1369 1371
1372Note that this guarantee covers only accesses
1373syntactically inside the assignment statement.
1374If a function or a metamethod called during the assignment
1375changes the value of a variable,
1376Lua gives no guarantees about the order of that access.
1377
1370An assignment to a global name @T{x = val} 1378An assignment to a global name @T{x = val}
1371is equivalent to the assignment 1379is equivalent to the assignment
1372@T{_ENV.x = val} @see{globalenv}. 1380@T{_ENV.x = val} @see{globalenv}.