null
Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.
Represents the null value and can prefix a null check.
Syntax: none [<expression>]
Category#
literal
Related#
Examples#
radix/corpus/literalia/nihil.fab (canonical · keyword)#
Null literal and nullable union bindings.
# =============================================================================
# none — Null literal and nullable union bindings.
# =============================================================================
#
# What this teaches:
# • the `none` literal — represents absence of a value (null)
# • nullable union types with `∪` — `T ∪ none` for values that may be absent
# • null checks with `est none` and `is not none`
#
# Common mistakes:
# • Using none without declaring the type as T ∪ none — none requires a nullable union type.
#
# See also: ∪, optional, none
# =============================================================================
# literalia/nihil — none literal and T ∪ none
#
# GRAMMAR:
# literal :← 'none'
# unionType :← type '∪' 'none'
#
# EXPECTED OUTPUT:
# none, true, 42
#
# BACKEND:
# Cross-ref none/nihil.fab.
fn maybe() → int ∪ none {
return 42
}
main {
const int ∪ none absent ← null
print absent
const bool nihilne ← absent is none
print nihilne
print maybe() not is none
}Expected output:
nihil
verum
verum
radix/corpus/nihil/nihil.fab (canonical · keyword)#
Represents the null value and can prefix a null check.
# =============================================================================
# none — Represents the null value and can prefix a null check.
# =============================================================================
#
# What this teaches:
# • the `none` keyword — used for null/none values
#
# Common mistakes:
# • Using none without ∪ in the type position — nullable types must be declared as T ∪ none.
#
# See also: ∪, optional
# =============================================================================
# none — null literal
#
# GRAMMAR:
# literal :← 'none'
#
# EXPECTED OUTPUT:
# Scalar stdout smoke (see body).
#
main {
const none nothing ← null
print nothing
}Expected output:
nihil