Renderingen-US

optional

Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.

Marks a named declaration slot (parameter or class field) as voluntary — the caller or provider may omit the value.

Aliases: optional, voluntary

Syntax: <type> <name> optional [= default | coalesce default]

Category#

declaration

Examples#

radix/corpus/sponte/sponte.fab (canonical · keyword)#

Marks a named declaration slot (parameter or class field) as voluntary — the caller or provider may omit the value.

# =============================================================================
# optional — Marks a named declaration slot (parameter or class field) as voluntary — the caller or provider may omit the value.
# =============================================================================
#
# What this teaches:
#   • Voluntary parameter syntax — using `optional` to mark function parameters or class fields as optional
#   • Default values — combining `optional` with `vel` to provide fallbacks when the value is omitted
#
# Common mistakes:
#   • confusing optional (optional parameter with a default) with ∪ none (nullable type) — optional marks omission, ∪ none marks absence
#
# See also: vel, none, ∪, fn, class
# =============================================================================



# optional — optional parameter / field marker
#
# GRAMMAR:
#   optionalMarker :← 'optional'
#
# EXPECTED OUTPUT:
#   No main — declaration or test-runner surface only.
#
# BACKEND:
#   declaration-only optional slots (whitelist: optional/sponte.fab). Cross-ref: optionalis/optionalis.fab.
#

fn greet(string name, string titulus optional) → string {
    return name
}

fn paginate(int pagina optional coalesce 1) → string {
    return "page"
}

class User {
    var string name
    var string email optional
}