可选
Translation status: 简体中文 reader-locale proof. Term names and code fences follow the zh-Hans pack; supporting prose may still be English.
Marks a named declaration slot (parameter or 类 field) as voluntary — the caller or provider may omit the value.
Aliases: optional, voluntary
Syntax: <type> <name> 可选 [= default | 兜底 default]
Category#
declaration
Related#
Examples#
radix/corpus/sponte/sponte.fab (canonical · keyword)#
Marks a named declaration slot (parameter or 类 field) as voluntary — the caller or provider may omit the value.
# =============================================================================
# 可选 — Marks a named declaration slot (parameter or 类 field) as voluntary — the caller or provider may omit the value.
# =============================================================================
#
# What this teaches:
# • Voluntary parameter syntax — using `可选` to mark function parameters or 类 fields as optional
# • Default values — combining `可选` with `vel` to provide fallbacks when the value is omitted
#
# Common mistakes:
# • confusing 可选 (optional parameter with a default) with ∪ 空类型 (nullable type) — 可选 marks omission, ∪ 空类型 marks absence
#
# See also: vel, 空类型, ∪, 函数, 类
# =============================================================================
# 可选 — optional parameter / field marker
#
# GRAMMAR:
# optionalMarker :← '可选'
#
# EXPECTED OUTPUT:
# No 入口 — declaration or test-runner surface only.
#
# BACKEND:
# declaration-only optional slots (whitelist: 可选/sponte.fab). Cross-ref: optionalis/optionalis.fab.
#
fn greet(string 名称, string titulus optional) → string {
return 名称
}
fn paginate(int pagina optional coalesce 1) → string {
return "page"
}
class User {
var string name
var string email optional
}