Details · lua/lua@262dc57 · GitHub
Skip to content

Commit 262dc57

Browse files
committed
Details
Corrections in comments and manual. Added note in the manual about local variables in the REPL.
1 parent 9d985db commit 262dc57

9 files changed

Lines changed: 36 additions & 21 deletions

File tree

‎lauxlib.c‎

Lines changed: 1 addition & 1 deletion

‎lgc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1541,7 +1541,7 @@ static void sweepstep (lua_State *L, global_State *g,
15411541
** object.) When 'fast' is true, 'singlestep' tries to finish a state
15421542
** "as fast as possible". In particular, it skips the propagation
15431543
** phase and leaves all objects to be traversed by the atomic phase:
1544-
** That avoids traversing twice some objects, such as theads and
1544+
** That avoids traversing twice some objects, such as threads and
15451545
** weak tables.
15461546
*/
15471547
static l_obj singlestep (lua_State *L, int fast) {

‎lgc.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
**
136136
** To keep its invariants, the generational mode uses the same barriers
137137
** also used by the incremental mode. If a young object is caught in a
138-
** foward barrier, it cannot become old immediately, because it can
138+
** forward barrier, it cannot become old immediately, because it can
139139
** still point to other young objects. Instead, it becomes 'old0',
140140
** which in the next cycle becomes 'old1'. So, 'old0' objects is
141141
** old but can point to new and survival objects; 'old1' is old

‎lstate.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ typedef struct global_State {
259259
l_obj totalobjs; /* total number of objects allocated + GCdebt */
260260
l_obj GCdebt; /* objects counted but not yet allocated */
261261
l_obj marked; /* number of objects marked in a GC cycle */
262-
l_obj GCmajorminor; /* auxiliar counter to control major-minor shifts */
262+
l_obj GCmajorminor; /* auxiliary counter to control major-minor shifts */
263263
stringtable strt; /* hash table for strings */
264264
TValue l_registry;
265265
TValue nilvalue; /* a nil value */

‎lua.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ static int dostring (lua_State *L, const char *s, const char *name) {
211211
/*
212212
** Receives 'globname[=modname]' and runs 'globname = require(modname)'.
213213
** If there is no explicit modname and globname contains a '-', cut
214-
** the sufix after '-' (the "version") to make the global name.
214+
** the suffix after '-' (the "version") to make the global name.
215215
*/
216216
static int dolibrary (lua_State *L, char *globname) {
217217
int status;
@@ -230,7 +230,7 @@ static int dolibrary (lua_State *L, char *globname) {
230230
status = docall(L, 1, 1); /* call 'require(modname)' */
231231
if (status == LUA_OK) {
232232
if (suffix != NULL) /* is there a suffix mark? */
233-
*suffix = '\0'; /* remove sufix from global name */
233+
*suffix = '\0'; /* remove suffix from global name */
234234
lua_setglobal(L, globname); /* globname = require(modname) */
235235
}
236236
return report(L, status);

‎luaconf.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@
261261
/*
262262
** LUA_IGMARK is a mark to ignore all after it when building the
263263
** module name (e.g., used to build the luaopen_ function name).
264-
** Typically, the sufix after the mark is the module version,
264+
** Typically, the suffix after the mark is the module version,
265265
** as in "mod-v1.2.so".
266266
*/
267267
#define LUA_IGMARK "-"

‎lvm.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ static int l_strton (const TValue *obj, TValue *result) {
9292
if (!cvt2num(obj)) /* is object not a string? */
9393
return 0;
9494
else {
95-
TString *st = tsvalue(obj);
96-
size_t stlen;
97-
const char *s = getlstr(st, stlen);
98-
return (luaO_str2num(s, result) == stlen + 1);
95+
TString *st = tsvalue(obj);
96+
size_t stlen;
97+
const char *s = getlstr(st, stlen);
98+
return (luaO_str2num(s, result) == stlen + 1);
9999
}
100100
}
101101

‎manual/manual.of‎

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ Whenever there is an error,
289289
an @def{error object}
290290
is propagated with information about the error.
291291
Lua itself only generates errors whose error object is a string,
292-
but programs may generate errors with
292+
but programs can generate errors with
293293
any value as the error object.
294294
It is up to the Lua program or its host to handle such error objects.
295295
For historical reasons,
@@ -298,7 +298,7 @@ even though it does not have to be a string.
298298

299299

300300
When you use @Lid{xpcall} (or @Lid{lua_pcall}, in C)
301-
you may give a @def{message handler}
301+
you can give a @def{message handler}
302302
to be called in case of errors.
303303
This function is called with the original error object
304304
and returns a new error object.
@@ -343,7 +343,7 @@ which is then called a @def{metamethod}.
343343
In the previous example, the key is the string @St{__add}
344344
and the metamethod is the function that performs the addition.
345345
Unless stated otherwise,
346-
a metamethod may in fact be any @x{callable value},
346+
a metamethod can in fact be any @x{callable value},
347347
which is either a function or a value with a @idx{__call} metamethod.
348348

349349
You can query the metatable of any value
@@ -1421,7 +1421,7 @@ labels in Lua are considered statements too:
14211421

14221422
A label is visible in the entire block where it is defined,
14231423
except inside nested functions.
1424-
A goto may jump to any visible label as long as it does not
1424+
A goto can jump to any visible label as long as it does not
14251425
enter into the scope of a local variable.
14261426
A label should not be declared
14271427
where a label with the same name is visible,
@@ -4549,7 +4549,7 @@ corresponding Lua value is removed from the stack @see{constchar}.
45494549

45504550
This function can raise memory errors only
45514551
when converting a number to a string
4552-
(as then it may have to create a new string).
4552+
(as then it may create a new string).
45534553

45544554
}
45554555

@@ -6113,8 +6113,8 @@ The metatable is created by the I/O library
61136113

61146114
This userdata must start with the structure @id{luaL_Stream};
61156115
it can contain other data after this initial structure.
6116-
The field @id{f} points to the corresponding C stream
6117-
(or it can be @id{NULL} to indicate an incompletely created handle).
6116+
The field @id{f} points to the corresponding C stream,
6117+
or it is @id{NULL} to indicate an incompletely created handle.
61186118
The field @id{closef} points to a Lua function
61196119
that will be called to close the stream
61206120
when the handle is closed or collected;
@@ -9239,11 +9239,25 @@ Lua repeatedly prompts and waits for a line.
92399239
After reading a line,
92409240
Lua first try to interpret the line as an expression.
92419241
If it succeeds, it prints its value.
9242-
Otherwise, it interprets the line as a statement.
9243-
If you write an incomplete statement,
9242+
Otherwise, it interprets the line as a chunk.
9243+
If you write an incomplete chunk,
92449244
the interpreter waits for its completion
92459245
by issuing a different prompt.
92469246

9247+
Note that, as each complete line is read as a new chunk,
9248+
local variables do not outlive lines:
9249+
@verbatim{
9250+
> x = 20
9251+
> local x = 10; print(x) --> 10
9252+
> print(x) --> 20 -- global 'x'
9253+
> do -- incomplete line
9254+
>> local x = 10; print(x) -- '>>' prompts for line completion
9255+
>> print(x)
9256+
>> end -- line completed; Lua will run it as a single chunk
9257+
--> 10
9258+
--> 10
9259+
}
9260+
92479261
If the global variable @defid{_PROMPT} contains a string,
92489262
then its value is used as the prompt.
92499263
Similarly, if the global variable @defid{_PROMPT2} contains a string,

‎testes/pm.lua‎

Lines changed: 2 additions & 1 deletion

0 commit comments

Comments
 (0)