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