渲染zh-Hans

不变

Translation status: 简体中文 reader-locale proof. Term names and code fences follow the zh-Hans pack; supporting prose may still be English.

Marks a function as non-mutating.

Syntax: 函数 <name>(...) 不变 → <type>

Category#

function

Examples#

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

Marks a function as non-mutating.

# =============================================================================
# 不变 — Marks a function as non-mutating
# =============================================================================
#
# What this teaches:
#   • Marks a function as non-mutating.
#   • Related keywords: 可抛
#
# Common mistakes:
#   • Mutating state inside an `不变` function — `不变` is a non-mutation contract; modifying `传入` parameters or external state breaks the contract.
#
# See also: 可抛
# =============================================================================

# 不变 — immutability contract on 函数
#
# GRAMMAR:
#   funcModifier :← '不变'
#
# EXPECTED OUTPUT:
#   No 入口 — declaration or test-runner surface only.
#
# BACKEND:
#   declaration-only function modifier (whitelist: 不变/immutata.fab).
#

fn inspecta() readonly → int {
    return 0
}