văn_bản
Translation status: Tiếng Việt reader-locale proof. Term names and code fences follow the vi pack; supporting prose may still be English.
Primitive string/text type.
Aliases: string
Syntax: văn_bản
Category#
type
Related#
Examples#
radix/corpus/intrinseca/textus-transformationes.fab (canonical · keyword)#
Primitive string/text type.
# =============================================================================
# văn_bản — Primitive string/text type
# =============================================================================
#
# What this teaches:
# • Primitive string/text type.
# • Related keywords: string, văn_bản_hóa, ↦
#
# Common mistakes:
# • Using `văn_bản` transform methods on non-text types — `.slice()`, `.uppercase()`, `.lowercase()`, `.trim()`, `.split()`, `.replace()` are textus-only compiler intrinsics.
#
# See also: string, văn_bản_hóa, ↦
# =============================================================================
# văn_bản slice and transform intrinsics
#
# Compiler-owned văn_bản methodi — sectio, maiuscula, minuscula, recide,
# divide, muta.
#
# GRAMMAR:
# s.slice(lo, hi) | s.uppercase() | s.lowercase() | s.trim()
# s.split(sep) | s.replace(old, new)
#
# divide returns danh_sách<văn_bản>; pairs with danh_sách/ exempla for collection smoke.
# Derived locals use đặt to avoid repeating hằng _ across the transform chain.
# Wasm tier Runnable.
#
# EXPECTED OUTPUT:
# Smoke asserts exit 0 only.
main {
let nuntius ← " Ave Roma "
let secta ← nuntius.slice(1, 4)
let magna ← nuntius.uppercase()
let parva ← nuntius.lowercase()
let rasa ← nuntius.trim()
let partes ← rasa.split(" ")
let mutata ← rasa.replace("Roma", "Munde")
print secta, magna, parva
print rasa, partes, mutata
}radix/corpus/bounded/conversio-textus-overflow-decline.fab (supporting · reject)#
Decline: a văn_bản literal longer than the target capacity rejects with textus_literal_too_long.
# =============================================================================
# văn_bản overflow decline — literal over capacity fails closed
# =============================================================================
#
# Decline row (reject reason in the comment):
# 1. over capacity — `"abcdef" ↦ string<4>` asks a 6-scalar literal to fit
# a capacity of 4: SEM011 textus_literal_too_long
#
# Common mistakes:
# • expecting silent truncation — the D7 overflow rule fails closed at
# check for literals whose scalar count exceeds the target capacity
#
# See also: ↦, văn_bản
# =============================================================================
# văn_bản literal over capacity — expected compile failure
#
# WHY: pins the fail-closed overflow token in conversio-textus-overflow-decline.expected.
main {
const string<4> t ← "abcdef" ↦ string<4>
print t
}Expected: compilation rejects this example.
radix/corpus/bounded/conversio-textus-to-ascii-decline.fab (supporting · reject)#
Decline: bounded văn_bản<N> cannot convert directly to ascii<M>.
# =============================================================================
# bounded văn_bản to ascii — unsupported chuyển decline
# =============================================================================
#
# What this teaches:
# • Unicode text and bounded ASCII have different chuyển contracts.
# • The unsupported route fails closed with `SEM016:unsupported_conversio`.
#
# Common mistakes:
# • assuming every văn_bản value is ASCII-safe without an explicit narrowing
# check.
fn narrow(string<8> raw) → ascii<4> {
return raw ↦ ascii<4>
}Expected: compilation rejects this example.
radix/corpus/bounded/conversio-textus-to-bounded-textus-decline.fab (supporting · reject)#
Decline: bounded văn_bản<N> cannot resize directly to bounded văn_bản<M>.
# =============================================================================
# bounded văn_bản resize — unsupported chuyển decline
# =============================================================================
#
# What this teaches:
# • Bounded văn_bản capacities are not interchangeable through a direct
# resize chuyển.
# • The unsupported route fails closed with `SEM016:unsupported_conversio`.
#
# Common mistakes:
# • expecting a resize to truncate Unicode scalars silently.
fn resize(string<8> raw) → string<4> {
return raw ↦ string<4>
}Expected: compilation rejects this example.
radix/corpus/bounded/conversio-textus-to-octeti-decline.fab (supporting · reject)#
Decline: bounded văn_bản<N> cannot convert directly to byte<M>.
# =============================================================================
# bounded văn_bản to byte — unsupported chuyển decline
# =============================================================================
#
# What this teaches:
# • A bounded text carrier does not become a bounded byte carrier through a
# direct `↦` route.
# • The unsupported route fails closed with `SEM016:unsupported_conversio`.
#
# Common mistakes:
# • treating UTF-8 encoding as a width-only chuyển.
fn encode(string<8> raw) → bytes<8> {
return raw ↦ bytes<8>
}Expected: compilation rejects this example.