渲染zh-Hans

scriptum-display-option

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

A § slot shows an option exactly as print does: an absent option as 空类型, a present one as its value.

Syntax: \"<template>\"(<option>)

Category#

format

Examples#

radix/corpus/scriptum/scriptum-display-option.fab (canonical · concept)#

A § slot shows an option exactly as print does: an absent option as 空类型, a present one as its value.

# =============================================================================
# scriptum-display-option — an option in a `§` slot
# =============================================================================
#
# What this teaches:
#   • An absent option placed in a `§` slot reads `空类型`, exactly as a bare
#     `print` of it does; a present option reads as the value it holds.
#
# Common mistakes:
#   • Expecting the host language's spelling of an absent value (`null`,
#     `nil`, `None`) in the template text.
#
# See also: 格式化, scriptum-display
# =============================================================================

# scriptum-display-option — absent and present options inside `§` slots
#
# EXPECTED OUTPUT:
#   scriptum-display-option.expected — each template line, then the same values printed alone.

main {
    const int ∪ none absent ← null
    const int ∪ none present ← 4

    print "absent=§"(absent)
    print "present=§"(present)

    print absent
    print present
}

Expected output:

absent=nihil
present=4
nihil
4