The Carbon documentation refers to some types that may be uncommon to some Lua users. Types in the documentation with lowercase
names can be found here.
Standard Lua Types
These are types representable by the Lua type
function, some by different names.
string
This is a standard string type containing text or data.
number
This is any number, including nan
, inf
, and -inf
.
bool
A value representing true
or false
. Lua knows these as boolean
values.
nil
An explicitly empty, or non-existent value.
table
This refers to a table with any structure. Tables have two types of data storage, the list and dictionary parts. The list part may be traversed with ipairs
, while the dictionary part (which is a superset of the list part) can be traversed with pairs
.
userdata
Generated by C methods or through the newproxy
function.
coroutine
A Lua coroutine, generated by a few different standard Lua functions.
tuple
A loose grouping of values used when returning multiple values. A tuple<N, x, y, z>
denotes the length and constituent types of the tuple.
Extended Lua Types
These types are non-standard subsets of the standard array of Lua types. They specify more specific variants of the above primitives.
(x, y, z)
A conglomerate type indicating that this type can be any of the types x
, y
, or z
.
x?
Where x
is any other type, represnts that type or nil
. Known as a "nullable" type, since types are non-nullable by default.
This is the same as (x, nil)
.
loose<x>
Many types can be represented in a 'loose' form, often used for intermediate conversions to prevent allocations.
any
A generic type that any other type can fill.
FFI<x>
Denotes a type designed for the LuaJIT FFI. Only available under LuaJIT.
void
An explicitly empty, or non-existent value. This is used in place of nil
for method signatures.
indexable
A string
or table
, or a userdata
with an __index
metamethod. These types can have their members without throwing errors.
char
A single-character string
.
unumber
An unsigned, positive number
.
int
An integer.
uint
An unsigned, positive int
.
list
A table with data in the list part. Data can also exist in the dictionary part of the array, but it will not be used. A list can specify the types of its values, in the form of list<valuetype>
.
dictionary
A table
with data in the list or dictionary parts. A dictionary can specify the types of its keys and values, in the form of dictionary<keytype, valuetype>
.
set
An alias to dictionary<any, bool>
, that is, a dictionary whose keys can be anything, but whose values must be boolean. A set
is said to be "explicit" if it contains both true
and false
members, explicitly excluding members from the set by name.
Sets can override the default key type of any
using the form set<keytype>
.