Prelude
What every file sees without an import.
Contents
| Name | Summary |
|---|---|
null_t | The type of the null constant. |
Nullable | The type behind T?. |
__builtin_niche_of | Counts the bit patterns a T never holds, which the layout engine uses to store a T? without a tag: 1 for a pointer, the values past a plain enum's or an ADT tag's range, a record's first field's niches, and 0 for anything else. |
__builtin_type_id | Returns T's panic type id, the tag an Err holding a T is stored as. |
__builtin_panic_site | Returns the panic site id of this call, registered in the translation unit's __kairo_panic_sites table as a panic would be. |
__builtin_is_safe_pointer | Kairo-only type queries, answered at compile time for a concrete T. |
__builtin_is_unsafe_pointer | Returns true when T is an unsafe pointer (unsafe *U). |
__builtin_is_nullable | Returns true when T is a nullable type (U?). |
__builtin_is_adt_enum | Returns true when T is an enum with payload cases, not a plain enum. |
__builtin_is_class | Returns true when T is a class. |
__builtin_is_struct | Returns true when T is a struct. |
__builtin_is_tuple | Returns true when T is a tuple type. |
__builtin_tuple_arity | Returns the number of elements of the tuple type T. |
null_t
struct null_t
The type of the null constant.
Every null converts to a T?, and a C++ host spells the constant
::builtin::null. It carries nothing, so the struct is empty.
Nullable
enum <T> Nullable
The type behind T?. Kairo code spells it only as the ? suffix; C++ hosts name it.
It is an ADT, so the payload is a real T only while present: it is constructed in place and
destroyed exactly once, and copy and move follow T's own. Every implicit T -> T? and
null -> T? conversion is one of its constructors; C++ also gets is_null(), the unchecked
__value(), and == when T has one. The compiler may lay it out niche-filled (a null
pointer as the null case, for instance), so nothing may depend on the layout.
See also
__builtin_niche_of
Nullable.Value
Value
A present value: T? holding v.
Nullable.Null
Null
No value: what null assigns to a T?.
__builtin_niche_of
eval fn <T> __builtin_niche_of() -> u64
Counts the bit patterns a T never holds, which the layout engine uses to store a T? without
a tag: 1 for a pointer, the values past a plain enum's or an ADT tag's range, a record's first
field's niches, and 0 for anything else.
Answered at compile time: the compiler replaces every call with the count, so this body never runs. Compiler test hook; user code has no reason to call it.
__builtin_type_id
eval fn <T> __builtin_type_id() -> u32
Returns T's panic type id, the tag an Err holding a T is stored as. It is the same in
every translation unit.
Answered at compile time; this body never runs. Compiler test hook.
__builtin_panic_site
fn __builtin_panic_site() -> u32
Returns the panic site id of this call, registered in the translation unit's
__kairo_panic_sites table as a panic would be.
The compiler replaces every call with the id; this body never runs. Compiler test hook.
__builtin_is_safe_pointer
eval fn <T> __builtin_is_safe_pointer() -> bool
Kairo-only type queries, answered at compile time for a concrete T. C++ spells a safe and an
unsafe pointer alike, and a class, a struct and an ADT enum are all C++ structs, so only the
compiler can tell them apart. A T that depends on a generic parameter is an error, and these
bodies never run. The queries C++ can answer are in base/intrinsics.k.
Each returns true when T is a safe pointer (*U).
__builtin_is_unsafe_pointer
eval fn <T> __builtin_is_unsafe_pointer() -> bool
Returns true when T is an unsafe pointer (unsafe *U).
__builtin_is_nullable
eval fn <T> __builtin_is_nullable() -> bool
Returns true when T is a nullable type (U?).
__builtin_is_adt_enum
eval fn <T> __builtin_is_adt_enum() -> bool
Returns true when T is an enum with payload cases, not a plain enum.
__builtin_is_class
eval fn <T> __builtin_is_class() -> bool
Returns true when T is a class.
__builtin_is_struct
eval fn <T> __builtin_is_struct() -> bool
Returns true when T is a struct.
__builtin_is_tuple
eval fn <T> __builtin_is_tuple() -> bool
Returns true when T is a tuple type.
__builtin_tuple_arity
eval fn <T> __builtin_tuple_arity() -> usize
Returns the number of elements of the tuple type T.
Generated from Kairo source, Apache-2.0 WITH AdditionRef-Kairo-Runtime-exception.