渲染zh-Hant

scriptum

Translation status: 繁體中文 reader-locale proof. Code fences render through the zh-Hant pipeline; prose is canonical Latin.

Creates a formatted string with § placeholders.

Syntax: \"<template>\"(<args>...)

Category#

format

Examples#

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

Creates a formatted string with § placeholders.

# =============================================================================
# scriptum — Creates a formatted string with `§` placeholders.
# =============================================================================
#
# What this teaches:
#   • String template interpolation — `"template § and §"(arg1, arg2)` replaces
#     `§` placeholders with positional arguments
#   • Templates can contain any expression as an argument, not just variables
#
# Common mistakes:
#   • Confusing `scriptum` (template desugaring into function calls) with bare `§` interpolation outside of the template syntax.
#
# See also: lege, lineam
# =============================================================================



# scriptum — string-template interpolation ("§" slots)
#
# "literal § more §"(arg1, arg2)   -- each § replaced by the corresponding arg
#
# GRAMMAR:
#   templateExpr :← stringLit '(' exprList ')'
#
# EXPECTED OUTPUT:
#   Salve greeting, persona notice, and computed summa string.

main {
    const _ nomen  "Marcus"
    const _ aetas  30

    # One slot
    const _ salutatio  "Salve, §!"(nomen)
    print salutatio

    # Multiple slots
    const _ notitia  "§ habet annos §"(nomen, aetas)
    print notitia

    # With an expression
    const _ summa  "10 + 20 ← §"(10 + 20)
    print summa
}

Expected output:

Salve, Marcus!
Marcus habet annos 30
10 + 20 ← 30