diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-08-15 13:44:36 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-08-15 13:44:36 -0300 |
commit | a1d8eb27431c02c4529be1efd92143ad65434f3a (patch) | |
tree | 58db9340ba2b8ea1cb91004b96f15a955f167c58 /manual | |
parent | f64a1b175a5fa65434a073e6d071b32bb7b0ab69 (diff) | |
download | lua-a1d8eb27431c02c4529be1efd92143ad65434f3a.tar.gz lua-a1d8eb27431c02c4529be1efd92143ad65434f3a.tar.bz2 lua-a1d8eb27431c02c4529be1efd92143ad65434f3a.zip |
Added control messages to warnings
Added the concept of control messages to the warning system, plus the
implementation of the controls "@on"/"@off" to turn warnings on/off.
Moreover, the warning system in the test library adds some other
controls to ease the test of warnings.
Diffstat (limited to 'manual')
-rw-r--r-- | manual/manual.of | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/manual/manual.of b/manual/manual.of index ff27a7d4..8c71c613 100644 --- a/manual/manual.of +++ b/manual/manual.of | |||
@@ -4370,6 +4370,8 @@ The third parameter is a boolean that | |||
4370 | indicates whether the message is | 4370 | indicates whether the message is |
4371 | to be continued by the message in the next call. | 4371 | to be continued by the message in the next call. |
4372 | 4372 | ||
4373 | See @Lid{warn} for more details about warnings. | ||
4374 | |||
4373 | } | 4375 | } |
4374 | 4376 | ||
4375 | @APIEntry{ | 4377 | @APIEntry{ |
@@ -4380,6 +4382,8 @@ Emits a warning with the given message. | |||
4380 | A message in a call with @id{tocont} true should be | 4382 | A message in a call with @id{tocont} true should be |
4381 | continued in another call to this function. | 4383 | continued in another call to this function. |
4382 | 4384 | ||
4385 | See @Lid{warn} for more details about warnings. | ||
4386 | |||
4383 | } | 4387 | } |
4384 | 4388 | ||
4385 | @APIEntry{ | 4389 | @APIEntry{ |
@@ -6355,6 +6359,16 @@ The current value of this variable is @St{Lua 5.4}. | |||
6355 | Emits a warning with a message composed by the concatenation | 6359 | Emits a warning with a message composed by the concatenation |
6356 | of all its arguments (which should be strings). | 6360 | of all its arguments (which should be strings). |
6357 | 6361 | ||
6362 | By convention, | ||
6363 | a one-piece message starting with @Char{@At} | ||
6364 | is intended to be a @emph{control message}, | ||
6365 | which is a message to the warning system itself. | ||
6366 | In particular, the standard warning function in Lua | ||
6367 | recognizes the control messages @St{@At{}off}, | ||
6368 | to stop the emission of warnings, | ||
6369 | and @St{@At{}on}, to (re)start the emission; | ||
6370 | it ignores unknown control messages. | ||
6371 | |||
6358 | } | 6372 | } |
6359 | 6373 | ||
6360 | @LibEntry{xpcall (f, msgh [, arg1, @Cdots])| | 6374 | @LibEntry{xpcall (f, msgh [, arg1, @Cdots])| |
@@ -7293,7 +7307,7 @@ stored as the first capture, and therefore has @N{number 1}; | |||
7293 | the character matching @St{.} is captured with @N{number 2}, | 7307 | the character matching @St{.} is captured with @N{number 2}, |
7294 | and the part matching @St{%s*} has @N{number 3}. | 7308 | and the part matching @St{%s*} has @N{number 3}. |
7295 | 7309 | ||
7296 | As a special case, the empty capture @T{()} captures | 7310 | As a special case, the capture @T{()} captures |
7297 | the current string position (a number). | 7311 | the current string position (a number). |
7298 | For instance, if we apply the pattern @T{"()aa()"} on the | 7312 | For instance, if we apply the pattern @T{"()aa()"} on the |
7299 | string @T{"flaaap"}, there will be two captures: @N{3 and 5}. | 7313 | string @T{"flaaap"}, there will be two captures: @N{3 and 5}. |
@@ -7858,7 +7872,6 @@ they are compared as @x{unsigned integers}. | |||
7858 | 7872 | ||
7859 | } | 7873 | } |
7860 | 7874 | ||
7861 | |||
7862 | @sect2{iolib| @title{Input and Output Facilities} | 7875 | @sect2{iolib| @title{Input and Output Facilities} |
7863 | 7876 | ||
7864 | The I/O library provides two different styles for file manipulation. | 7877 | The I/O library provides two different styles for file manipulation. |
@@ -8150,7 +8163,6 @@ There are three available modes: | |||
8150 | @item{@St{line}| line buffering.} | 8163 | @item{@St{line}| line buffering.} |
8151 | } | 8164 | } |
8152 | 8165 | ||
8153 | } | ||
8154 | For the last two cases, | 8166 | For the last two cases, |
8155 | @id{size} is a hint for the size of the buffer, in bytes. | 8167 | @id{size} is a hint for the size of the buffer, in bytes. |
8156 | The default is an appropriate size. | 8168 | The default is an appropriate size. |
@@ -8708,6 +8720,7 @@ The options are: | |||
8708 | @item{@T{-i}| enters interactive mode after running @rep{script};} | 8720 | @item{@T{-i}| enters interactive mode after running @rep{script};} |
8709 | @item{@T{-v}| prints version information;} | 8721 | @item{@T{-v}| prints version information;} |
8710 | @item{@T{-E}| ignores environment variables;} | 8722 | @item{@T{-E}| ignores environment variables;} |
8723 | @item{@T{-q}| turn warnings off;} | ||
8711 | @item{@T{--}| stops handling options;} | 8724 | @item{@T{--}| stops handling options;} |
8712 | @item{@T{-}| executes @id{stdin} as a file and stops handling options.} | 8725 | @item{@T{-}| executes @id{stdin} as a file and stops handling options.} |
8713 | } | 8726 | } |
@@ -8733,12 +8746,13 @@ setting the values of | |||
8733 | @Lid{package.path} and @Lid{package.cpath} | 8746 | @Lid{package.path} and @Lid{package.cpath} |
8734 | with the default paths defined in @id{luaconf.h}. | 8747 | with the default paths defined in @id{luaconf.h}. |
8735 | 8748 | ||
8736 | All options are handled in order, except @T{-i} and @T{-E}. | 8749 | The options @T{-e}, @T{-l}, and @T{-q} are handled in |
8750 | the order they appear. | ||
8737 | For instance, an invocation like | 8751 | For instance, an invocation like |
8738 | @verbatim{ | 8752 | @verbatim{ |
8739 | $ lua -e'a=1' -e 'print(a)' script.lua | 8753 | $ lua -e 'a=1' -llib1 script.lua |
8740 | } | 8754 | } |
8741 | will first set @id{a} to 1, then print the value of @id{a}, | 8755 | will first set @id{a} to 1, then require the library @id{lib1}, |
8742 | and finally run the file @id{script.lua} with no arguments. | 8756 | and finally run the file @id{script.lua} with no arguments. |
8743 | (Here @T{$} is the shell prompt. Your prompt may be different.) | 8757 | (Here @T{$} is the shell prompt. Your prompt may be different.) |
8744 | 8758 | ||
@@ -8798,7 +8812,8 @@ has a metamethod @idx{__tostring}, | |||
8798 | the interpreter calls this metamethod to produce the final message. | 8812 | the interpreter calls this metamethod to produce the final message. |
8799 | Otherwise, the interpreter converts the error object to a string | 8813 | Otherwise, the interpreter converts the error object to a string |
8800 | and adds a stack traceback to it. | 8814 | and adds a stack traceback to it. |
8801 | Warnings are simply printed in the standard error output. | 8815 | When warnings are on, |
8816 | they are simply printed in the standard error output. | ||
8802 | 8817 | ||
8803 | When finishing normally, | 8818 | When finishing normally, |
8804 | the interpreter closes its main Lua state | 8819 | the interpreter closes its main Lua state |