aboutsummaryrefslogtreecommitdiff
path: root/manual
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-05-08 17:50:10 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-05-08 17:50:10 -0300
commit262dc5729a28b2bad0b6413d4eab2290d14395cf (patch)
treec92cbf6c6d5d88bc352dd71f7f27be4dd44cf16f /manual
parent9d985db7bb09c92b5b3fa660fffe5907d01e6a02 (diff)
downloadlua-262dc5729a28b2bad0b6413d4eab2290d14395cf.tar.gz
lua-262dc5729a28b2bad0b6413d4eab2290d14395cf.tar.bz2
lua-262dc5729a28b2bad0b6413d4eab2290d14395cf.zip
Details
Corrections in comments and manual. Added note in the manual about local variables in the REPL.
Diffstat (limited to 'manual')
-rw-r--r--manual/manual.of32
1 files changed, 23 insertions, 9 deletions
diff --git a/manual/manual.of b/manual/manual.of
index 7df32fcf..5aea2623 100644
--- a/manual/manual.of
+++ b/manual/manual.of
@@ -289,7 +289,7 @@ Whenever there is an error,
289an @def{error object} 289an @def{error object}
290is propagated with information about the error. 290is propagated with information about the error.
291Lua itself only generates errors whose error object is a string, 291Lua itself only generates errors whose error object is a string,
292but programs may generate errors with 292but programs can generate errors with
293any value as the error object. 293any value as the error object.
294It is up to the Lua program or its host to handle such error objects. 294It is up to the Lua program or its host to handle such error objects.
295For historical reasons, 295For historical reasons,
@@ -298,7 +298,7 @@ even though it does not have to be a string.
298 298
299 299
300When you use @Lid{xpcall} (or @Lid{lua_pcall}, in C) 300When you use @Lid{xpcall} (or @Lid{lua_pcall}, in C)
301you may give a @def{message handler} 301you can give a @def{message handler}
302to be called in case of errors. 302to be called in case of errors.
303This function is called with the original error object 303This function is called with the original error object
304and returns a new error object. 304and returns a new error object.
@@ -343,7 +343,7 @@ which is then called a @def{metamethod}.
343In the previous example, the key is the string @St{__add} 343In the previous example, the key is the string @St{__add}
344and the metamethod is the function that performs the addition. 344and the metamethod is the function that performs the addition.
345Unless stated otherwise, 345Unless stated otherwise,
346a metamethod may in fact be any @x{callable value}, 346a metamethod can in fact be any @x{callable value},
347which is either a function or a value with a @idx{__call} metamethod. 347which is either a function or a value with a @idx{__call} metamethod.
348 348
349You can query the metatable of any value 349You can query the metatable of any value
@@ -1421,7 +1421,7 @@ labels in Lua are considered statements too:
1421 1421
1422A label is visible in the entire block where it is defined, 1422A label is visible in the entire block where it is defined,
1423except inside nested functions. 1423except inside nested functions.
1424A goto may jump to any visible label as long as it does not 1424A goto can jump to any visible label as long as it does not
1425enter into the scope of a local variable. 1425enter into the scope of a local variable.
1426A label should not be declared 1426A label should not be declared
1427where a label with the same name is visible, 1427where a label with the same name is visible,
@@ -4549,7 +4549,7 @@ corresponding Lua value is removed from the stack @see{constchar}.
4549 4549
4550This function can raise memory errors only 4550This function can raise memory errors only
4551when converting a number to a string 4551when 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).
4553 4553
4554} 4554}
4555 4555
@@ -6113,8 +6113,8 @@ The metatable is created by the I/O library
6113 6113
6114This userdata must start with the structure @id{luaL_Stream}; 6114This userdata must start with the structure @id{luaL_Stream};
6115it can contain other data after this initial structure. 6115it can contain other data after this initial structure.
6116The field @id{f} points to the corresponding C stream 6116The field @id{f} points to the corresponding C stream,
6117(or it can be @id{NULL} to indicate an incompletely created handle). 6117or it is @id{NULL} to indicate an incompletely created handle.
6118The field @id{closef} points to a Lua function 6118The field @id{closef} points to a Lua function
6119that will be called to close the stream 6119that will be called to close the stream
6120when the handle is closed or collected; 6120when the handle is closed or collected;
@@ -9239,11 +9239,25 @@ Lua repeatedly prompts and waits for a line.
9239After reading a line, 9239After reading a line,
9240Lua first try to interpret the line as an expression. 9240Lua first try to interpret the line as an expression.
9241If it succeeds, it prints its value. 9241If it succeeds, it prints its value.
9242Otherwise, it interprets the line as a statement. 9242Otherwise, it interprets the line as a chunk.
9243If you write an incomplete statement, 9243If you write an incomplete chunk,
9244the interpreter waits for its completion 9244the interpreter waits for its completion
9245by issuing a different prompt. 9245by issuing a different prompt.
9246 9246
9247Note that, as each complete line is read as a new chunk,
9248local 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
9247If the global variable @defid{_PROMPT} contains a string, 9261If the global variable @defid{_PROMPT} contains a string,
9248then its value is used as the prompt. 9262then its value is used as the prompt.
9249Similarly, if the global variable @defid{_PROMPT2} contains a string, 9263Similarly, if the global variable @defid{_PROMPT2} contains a string,