readonly
Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.
Marks a function as non-mutating.
Syntax: fn <name>(...) readonly → <type>
Category#
function
Related#
Examples#
radix/corpus/immutata/immutata.fab (canonical · keyword)#
Marks a function as non-mutating.
# =============================================================================
# readonly — Marks a function as non-mutating
# =============================================================================
#
# What this teaches:
# • Marks a function as non-mutating.
# • Related keywords: throws
#
# Common mistakes:
# • Mutating state inside an `readonly` function — `readonly` is a non-mutation contract; modifying `mut` parameters or external state breaks the contract.
#
# See also: throws
# =============================================================================
# readonly — immutability contract on fn
#
# GRAMMAR:
# funcModifier :← 'readonly'
#
# EXPECTED OUTPUT:
# No main — declaration or test-runner surface only.
#
# BACKEND:
# declaration-only function modifier (whitelist: readonly/immutata.fab).
#
fn inspecta() readonly → int {
return 0
}