Renderingen-US

Experimental through version 1. Version 0 was alpha. This is the first language release: the interface is relatively stable, not frozen. Nothing is promised stable until version 2.

ascii

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

Single-quoted ASCII machine-text literals.

Aliases: '...'

Syntax: '<text>'

Category#

literal

Examples#

radix/corpus/reference/existing-home/ascii/ascii.fab (canonical · existing-home)#

Single-quoted ASCII machine-text literals.

# =============================================================================
# ascii — Single-quoted ASCII machine-text literals.
# =============================================================================
#
# What this teaches:
#   • single-quoted ASCII literals `'...'` — compact syntax for machine-facing strings like route paths
#
# Common mistakes:
#   • Including non-ASCII characters in ascii literals — ascii literals are ASCII-only; use "..." for Unicode string.
#
# See also: string, string
# =============================================================================

# literalia/ascii — '...' literals
#
# EXPECTED OUTPUT:
#   pg:query

main {
    let ascii route ← 'pg:query'
    print route
}

Expected output:

pg:query

radix/corpus/reference/reject/ascii/ascii-methods-argument-reject.fab (supporting · reject)#

Rejected: a multi-byte ascii<size N> value is not an implicit string argument of a text method.

# =============================================================================
# ascii<size N> argument to a text method — rejected
# =============================================================================
#
# What this teaches:
#   • Only bare `ascii` and one-letter `ascii<size 1>` widen to `string` on their
#     own. An `ascii<size 4>` value reaches `string` through an explicit `↦ string`.
#   • The checker refuses the call with one named diagnostic, so `faber check`
#     and `faber check --lower` agree.
#
# Common mistakes:
#   • Passing a bounded `ascii<size N>` value straight to starts_with, ends_with,
#     replace or split.
# =============================================================================

main {
    let ascii<size 16> a ← ' Hello '
    let ascii<size 4> prefix ← ' H'
    print a.starts_with(prefix)
}

Expected: compilation rejects this example.

radix/corpus/reference/reject/ascii/conversio-ascii-overflow-decline.fab (supporting · reject)#

Decline: an ascii literal longer than the target capacity rejects with ascii_literal_too_long.

# =============================================================================
# ascii overflow decline — literal over capacity fails closed
# =============================================================================
#
# Decline row (reject reason in the comment):
#   1. over capacity — `'alpha' ↦ ascii<size 4>` asks a 5-byte literal to fit a
#      capacity of 4: SEM011 ascii_literal_too_long
#
# Common mistakes:
#   • expecting silent truncation — the D7 overflow rule fails closed at
#     check for literals whose byte count exceeds the target capacity
#
# See also: ↦, ascii
# =============================================================================

# ascii literal over capacity — expected compile failure
#
# WHY: pins the fail-closed overflow token in conversio-ascii-overflow-decline.expected.

main {
    let ascii<size 4> a ← 'alpha' ↦ ascii<size 4>
    print a
}

Expected: compilation rejects this example.