Renderingen-US

scriptum-display

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

A § slot shows each value exactly as print does: booleans as true/false, a whole float with .0.

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

Category#

format

Examples#

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

A § slot shows each value exactly as print does: booleans as true/false, a whole float with .0.

# =============================================================================
# scriptum-display — a `§` slot and `print` show a value the same way
# =============================================================================
#
# What this teaches:
#   • A scalar placed in a `§` slot is displayed by the same rule as a bare
#     `print` of it: a boolean as the language's own spelling (never the
#     host language's), a whole float keeping its `.0`.
#   • The text of a template and the text printed line by line agree on every
#     backend.
#
# Common mistakes:
#   • Expecting a whole float to lose its fraction in a template (`2` for
#     `2.0`); it prints `2.0`.
#
# See also: format, write
# =============================================================================

# scriptum-display — scalar spellings inside `§` slots
#
# EXPECTED OUTPUT:
#   scriptum-display.expected — each template line, then the same values printed alone.

fn half(float x) → float {
    return x / 2.0
}

main {
    const bool yes ← true
    const bool no ← false
    const float whole ← 2.0
    const float frac ← 2.5
    const int count ← 7
    const string word ← "hi"

    print "yes=§"(yes)
    print "no=§"(no)
    print "whole=§"(whole)
    print "frac=§"(frac)
    print "count=§"(count)
    print "word=§"(word)
    print "computed=§"(half(5.0))
    print "negated=§"(1 ≻ 2)
    print "literal=§"(3.0)

    print yes
    print no
    print whole
    print frac
    print count
    print word
}

Expected output:

yes=verum
no=falsum
whole=2.0
frac=2.5
count=7
word=hi
computed=2.5
negated=falsum
literal=3.0
verum
falsum
2.0
2.5
7
hi