summaryrefslogtreecommitdiff
path: root/manual
Commit message (Collapse)AuthorAgeFilesLines
...
* Manual corrected with the new syntax for attributesRoberto Ierusalimschy2019-08-161-5/+5
| | | | | Commit 0d529138042, with the change in the syntax of attributes, did not update the manual accordingly.
* Added macro 'luaL_pushfail'Roberto Ierusalimschy2019-08-162-36/+52
| | | | | | | | The macro 'luaL_pushfail' documents all places in the standard libraries that return nil to signal some kind of failure. It is defined as 'lua_pushnil'. The manual also got a notation (@fail) to document those returns. The tests were changed to be agnostic regarding whether 'fail' is 'nil' or 'false'.
* Supressed errors in '__close' generate warningsRoberto Ierusalimschy2019-08-161-1/+1
|
* Added control messages to warningsRoberto Ierusalimschy2019-08-151-7/+22
| | | | | | | 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.
* Detail in the manual (method 'file:setvbuf')Roberto Ierusalimschy2019-08-121-16/+8
| | | | | ANSI C is vague about 'setvbuf'; most details are implementation defined. So, the manual cannot give any guaranties, either.
* Correction in the documentation of 'io.lines'Roberto Ierusalimschy2019-07-311-6/+4
| | | | | | The loop does not end on end of file, but when the iterator function fails to read a value. (In particular, the format "a" never fails, so a loop with 'io.lines(fname, "a")' never ends.)
* To-be-closed variables must be closed on initializationRoberto Ierusalimschy2019-07-311-8/+11
| | | | | | | | | When initializing a to-be-closed variable, check whether it has a '__close' metamethod (or is a false value) and raise an error if if it hasn't. This produces more accurate error messages. (The check before closing still need to be done: in the C API, the value is not constant; and the object may lose its '__close' metamethod during the block.)
* 'math.randomseed' always returns the two seed componentsRoberto Ierusalimschy2019-07-191-2/+4
|
* 'math.randomseed()' returns the seeds it usedRoberto Ierusalimschy2019-07-171-0/+3
| | | | | A call to 'math.randomseed()' returns the two components of the seed it set, so that they can be used to set that same seed again.
* '__close' method may be called again in case of errorRoberto Ierusalimschy2019-07-161-5/+6
| | | | | | | | | An error in a closing method may be caused by a lack of resources, such as memory or stack space, and the error may free enough resources (by unwinding the stack) to allow the method to work if called again. If the closing method is already running after some error (including its own), it is not called again.
* First implementation of constant propagationRoberto Ierusalimschy2019-07-121-12/+19
| | | | | Local constant variables initialized with compile-time constants are optimized away from the code.
* Local attributes can be used in list of local variablesRoberto Ierusalimschy2019-07-031-26/+34
| | | | | | | | | | | | The syntax for local attributes ('const'/'toclose') was unified with the regular syntax for local variables, so that we can have variables with attributes in local definitions with multiple names; for instance: local <toclose> f, <const> err = io.open(fname) This new syntax does not implement constant propagation, yet. This commit also has some small improvements to the manual.
* New function 'setCstacklimit'Roberto Ierusalimschy2019-06-181-0/+42
| | | | | Added new functions to dynamically set the C-stack limit ('lua_setCstacklimit' in the C-API, 'debug.setCstacklimit' in Lua).
* Detail in the manualRoberto Ierusalimschy2019-06-101-5/+6
| | | | | More precision describing the variables that won't be closed if a coroutine yields forever.
* Updated the documentation for the API function 'lua_gc'v5.4-alphaRoberto Ierusalimschy2019-06-061-53/+62
|
* Multiple errors in '__toclose' report the first oneRoberto Ierusalimschy2019-06-051-6/+15
| | | | | | | | When there are multiple errors when closing objects, the error reported by the protected call is the first one, for two reasons: First, other errors may be caused by this one; second, the first error is handled in the original execution context, and therefore has the full traceback.
* Function 'warn' is varargRoberto Ierusalimschy2019-06-041-5/+3
| | | | | | | Instead of a 'tocont' flag, the function 'warn' in Lua now receives all message pieces as multiple arguments in a single call. Besides being simpler to use, this implementation ensures that Lua code cannot create unfinished warnings.
* 'coroutine.kill' renamed 'coroutine.close'Roberto Ierusalimschy2019-06-031-14/+15
|
* DetailsRoberto Ierusalimschy2019-06-031-3/+2
| | | | | Several small changes from feedback on 5.4 alhpa rc1 (warnings, typos in the manual, and the like)
* DetailsRoberto Ierusalimschy2019-05-281-5/+8
| | | | | | | - new error message for "attempt to assign to const variable" - note in the manual about compatibility options - comments - small changes in 'read_line' and 'pushstr'
* First implementation for 'const' variablesRoberto Ierusalimschy2019-05-171-8/+20
| | | | | A variable can be declared const, which means it cannot be assigned to, with the syntax 'local <const> name = exp'.
* Flag for to-be-closed variables changed to '<toclose>'Roberto Ierusalimschy2019-05-091-2/+2
| | | | | | | The flag for to-be-closed variables was changed from '*toclose' to '<toclose>'. Several people found confusing the old syntax and the new one has a clear terminator, making it more flexible for future changes.
* Coroutines do not unwind the stack in case of errorsRoberto Ierusalimschy2019-05-091-8/+25
| | | | | | | | | | | Back to how it was, a coroutine does not unwind its stack in case of errors (and therefore do not close its to-be-closed variables). This allows the stack to be examined after the error. The program can use 'coroutine.kill' to close the variables. The function created by 'coroutine.wrap', however, closes the coroutine's variables in case of errors, as it is impossible to examine the stack any way.
* New function 'luaL_addgsub'Roberto Ierusalimschy2019-04-241-2/+33
| | | | | | | | Added a new function 'luaL_addgsub', similar to 'luaL_gsub' but that adds its result directly to a preexisting buffer, avoiding the creation of one extra intermediate string. Also added two simple macros, 'luaL_bufflen' and 'luaL_buffaddr', to query the current length and the contents address of a buffer.
* 'require' returns where module was foundRoberto Ierusalimschy2019-04-171-11/+27
| | | | | The function 'require' returns the *loader data* as a second result. For file searchers, this data is the path where they found the module.
* Added an optional parameter to 'coroutine.isyieldable'Roberto Ierusalimschy2019-04-101-3/+4
|
* 'print' does not call 'tostring' to format its argumentsRoberto Ierusalimschy2019-04-101-2/+11
|
* Thorough revision of the reference manualRoberto Ierusalimschy2019-04-101-341/+351
|
* Year in copyright notice updated to 2019Roberto Ierusalimschy2019-03-251-1/+1
|
* Name 'nonstrict' in the UTF-8 library changed to 'lax'Roberto Ierusalimschy2019-03-191-4/+4
| | | | | It is not a good idea to use negative words to describe boolean values. (When we negate that boolean we create a double negative...)
* New semantics for the integer 'for' loopRoberto Ierusalimschy2019-03-191-70/+54
| | | | | | | | | | | The numerical 'for' loop over integers now uses a precomputed counter to control its number of iteractions. This change eliminates several weird cases caused by overflows (wrap-around) in the control variable. (It also ensures that every integer loop halts.) Also, the special opcodes for the usual case of step==1 were removed. (The new code is already somewhat complex for the usual case, but efficient.)
* Changes in the validation of UTF-8Roberto Ierusalimschy2019-03-151-4/+39
| | | | | | | | | | | All UTF-8 encoding functionality (including the escape sequence '\u') accepts all values from the original UTF-8 specification (with sequences of up to six bytes). By default, the decoding functions in the UTF-8 library do not accept invalid Unicode code points, such as surrogates. A new parameter 'nonstrict' makes them accept all code points up to (2^31)-1, as in the original UTF-8 specification.
* Finalizers must be callableRoberto Ierusalimschy2019-03-141-4/+19
| | | | | Non-function __gc metamethods are not ignored; if present, the metamethod will be called even if it is not a function.
* Changes in the warning systemRoberto Ierusalimschy2019-03-141-13/+13
| | | | | | | | - The warning functions get an extra parameter that tells whether message is to be continued (instead of using end-of-lines as a signal). - The user data for the warning function is a regular value, instead of a writable slot inside the Lua state.
* 'math.randomseed()' sets a somewhat random seedRoberto Ierusalimschy2019-03-131-9/+14
| | | | | | When called with no arguments, 'math.randomseed' uses time and ASLR to generate a somewhat random seed. the initial seed when Lua starts is generated this way.
* New conversion specifier '%p' for 'string.format'Roberto Ierusalimschy2019-03-131-3/+10
| | | | | The call 'string.format("%p", val)' gives a Lua equivalent to the C API function 'lua_topointer'.
* DetailsRoberto Ierusalimschy2019-03-131-22/+32
| | | | | | | | | | Several small improvements (code style, warnings, comments, more tests), in particular: - 'lua_topointer' extended to handle strings - raises an error in 'string.format("%10q")' ('%q' with modifiers) - in the manual for 'string.format', the term "option" replaced by "conversion specifier" (the term used by the C standard)
* Optional 'init' argument to 'string.gmatch'Roberto Ierusalimschy2019-01-081-19/+23
| | | | | | | | | The function 'string.gmatch' now has an optional 'init' argument, similar to 'string.find' and 'string.match'. Moreover, there was some reorganization in the manipulation of indices in the string library. This commit also includes small janitorial work in the manual and in comments in the interpreter loop.
* No more to-be-closed functionsRoberto Ierusalimschy2019-01-041-20/+14
| | | | | | | | | | | | | | | | | | | To-be-closed variables must contain objects with '__toclose' metamethods (or nil). Functions were removed for several reasons: * Functions interact badly with sandboxes. If a sandbox raises an error to interrupt a script, a to-be-closed function still can hijack control and continue running arbitrary sandboxed code. * Functions interact badly with coroutines. If a coroutine yields and is never resumed again, its to-be-closed functions will never run. To-be-closed objects, on the other hand, will still be closed, provided they have appropriate finalizers. * If you really need a function, it is easy to create a dummy object to run that function in its '__toclose' metamethod. This comit also adds closing of variables in case of panic.
* No more LUA_ERRGCMM errorsRoberto Ierusalimschy2019-01-011-17/+9
| | | | | Errors in finalizers (__gc metamethods) are never propagated. Instead, they generate a warning.
* Added a warning system to LuaRoberto Ierusalimschy2018-12-281-8/+48
| | | | | The warning system is just a way for Lua to emit warnings, messages to the programmer that do not interfere with the running program.
* Detailsalternative-versionalt-versionRoberto Ierusalimschy2018-12-171-8/+8
| | | | | A few details in the makefile and in the manual. (In particular, it updates the dependency lists in the makefile.)
* New functions 'lua_resetthread' and 'coroutine.kill'Roberto Ierusalimschy2018-12-131-4/+30
| | | | | | New functions to reset/kill a thread/coroutine, mainly (only?) to close any pending to-be-closed variable. ('lua_resetthread' also allows a thread to be reused...)
* Better error messages for some polymorphic functionsRoberto Ierusalimschy2018-12-101-0/+26
| | | | | | | | | New auxiliary functions/macros 'luaL_argexpected'/'luaL_typeerror' ease the creation of error messages such as bad argument #2 to 'setmetatable' (nil or table expected, got boolean) (The novelty being the "got boolean" part...)
* Calls cannot be tail in the scope of a to-be-closed variableRoberto Ierusalimschy2018-12-041-9/+8
| | | | | | A to-be-closed variable must be closed when a block ends, so even a 'return foo()' cannot directly returns the results of 'foo'; the function must close the scope before returning.
* A to-be-closed variable must have a closable value (or be nil)Roberto Ierusalimschy2018-11-291-9/+16
| | | | | | | It is an error for a to-be-closed variable to have a non-closable non-nil value when it is being closed. This situation does not seem to be useful and often hints to an error. (Particularly in the C API, it is easy to change a to-be-closed index by mistake.)
* Documentation for to-be-closed variablesRoberto Ierusalimschy2018-11-131-26/+122
|
* Removed resource-related "emergency collections"Roberto Ierusalimschy2018-10-311-14/+0
| | | | | New to-be-closed variables is a better way to ensure the proper release of resources.
* Small improvements in the manualRoberto Ierusalimschy2018-10-221-8/+18
|
* Deprecated the emulation of '__le' using '__lt'Roberto Ierusalimschy2018-08-241-12/+9
| | | | | | | | | | | As hinted in the manual for Lua 5.3, the emulation of the metamethod for '__le' using '__le' has been deprecated. It is slow, complicates the logic, and it is easy to avoid this emulation by defining a proper '__le' function. Moreover, often this emulation was used wrongly, with a programmer assuming that an order is total when it is not (e.g., NaN in floating-point numbers).