Home Explore Blog CI



neovim

3rd chunk of `runtime/doc/luaref.txt`
1d3b4c7f05ec1c5ab39fbed022b4dc04f4c0770e34751abc0000000100000fa3
 starts with an
opening long bracket of any level and ends at the first closing long bracket
of the same level. Literals in this bracketed form may run for several lines,
do not interpret any escape sequences, and ignore long brackets of any other
level. They may contain anything except a closing bracket of the proper level.

For convenience, when the opening long bracket is immediately followed by a
newline, the newline is not included in the string. As an example, in a system
using ASCII (in which `a` is coded as 97, newline is coded as 10, and `1` is
coded as 49), the five literals below denote the same string:
>lua
       a = 'alo\n123"'
       a = "alo\n123\""
       a = '\97lo\10\04923"'
       a = [[alo
       123"]]
       a = [==[
       alo
       123"]==]
<
                                                            *lua-numconstant*
A numerical constant may be written with an optional decimal part and an
optional decimal exponent. Lua also accepts integer hexadecimal constants, by
prefixing them with `0x`. Examples of valid numerical constants are
>
     3     3.0     3.1416  314.16e-2   0.31416E1   0xff   0x56
<
                                                                *lua-comment*
A comment starts with a double hyphen (`--`) anywhere outside a string. If the
text immediately after `--` is not an opening long bracket, the comment is a
short comment, which runs until the end of the line. Otherwise, it is a long
comment, which runs until the corresponding closing long bracket. Long
comments are frequently used to disable code temporarily.

==============================================================================
2.2  Values and Types                           *lua-values*

Lua is a dynamically typed language. This means that variables do not have
types; only values do. There are no type definitions in the language. All
values carry their own type.

All values in Lua are first-class values. This means that all values can be
stored in variables, passed as arguments to other functions, and returned as
results.

                                                *lua-types* *lua-nil*
                                                *lua-true* *lua-false*
                                                *lua-number* *lua-string*
There are eight basic types in Lua: `nil`, `boolean`, `number`, `string`,
`function`, `userdata`, `thread`, and `table`. Nil is the type of the value
`nil`, whose main property is to be different from any other value; it usually
represents the absence of a useful value. Boolean is the type of the values
`false` and `true`. Both `nil` and `false` make a condition false; any other
value makes it true. Number represents real (double-precision floating-point)
numbers. (It is easy to build Lua interpreters that use other internal
representations for numbers, such as single-precision float or long integers;
see file `luaconf.h`.) String represents arrays of characters. Lua is 8-bit
clean: strings may contain any 8-bit character, including embedded zeros
(`\0`) (see |lua-literal|).

Lua can call (and manipulate) functions written in Lua and functions written
in C (see |lua-function|).

                                                            *lua-userdatatype*
The type userdata is provided to allow arbitrary C data to be stored in Lua
variables. This type corresponds to a block of raw memory and has no
pre-defined operations in Lua, except assignment and identity test. However,
by using metatables, the programmer can define operations for userdata values
(see |lua-metatable|). Userdata values cannot be created or modified in Lua,
only through the C API. This guarantees the integrity of data owned by the
host program.

                                                                 *lua-thread*
The type `thread` represents independent threads of execution and it is used to
implement coroutines (see |lua-coroutine|). Do not confuse Lua threads with
operating-system threads. Lua supports coroutines

Title: Lua Values and Types: Numerical Constants, Comments, Basic Types, Userdata, and Threads
Summary
This section covers numerical constants (including hexadecimal), comments (short and long), Lua's dynamically typed nature, first-class values, and the eight basic types: nil, boolean, number, string, function, userdata, thread, and table. It details userdata's role in storing C data and threads for coroutines, emphasizing the distinction between Lua threads and OS threads.