การเรนเดอร์th-TH

ไบต์

Translation status: ภาษาไทย reader-locale proof. Term names and code fences follow the th-TH pack; supporting prose may still be English.

Primitive byte-buffer type.

Aliases: bytes

Syntax: ไบต์

Category#

type

Examples#

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

Primitive byte-buffer type.

# =============================================================================
# ไบต์ — Primitive byte-buffer type.
# =============================================================================
#
# What this teaches:
#   • Primitive buffer type — `ไบต์` is the built-in byte buffer, analogous to `Vec<u8>` in Rust.
#   • Literal syntax — Byte buffers can be written with hex literals like `|จาก ถึง be ef|`.
#
# Common mistakes:
#   • Writing ไบต์ hex literals with an odd digit count — each byte requires two hex digits.
#
# See also: ข้อความ, รายการ
# =============================================================================

# ไบต์ — byte-buffer type alias
#
# ชนิดนามแฝง Fascis = ไบต์
#
# GRAMMAR:
#   typeAliasDecl :← 'ชนิดนามแฝง' ident '=' typeExpr
#
# EXPECTED OUTPUT:
#   octeti.expected — type-known diagnostic.

type Fascis = bytes

main {
    const bytes sig ← |จาก ถึง be ef|
    const bytes hello ← |48 65 6c 6c 6f|
    const bytes empty ← ||
    print "octeti typus notus"
}

Expected output:

octeti typus notus

radix/corpus/bounded/conversio-octeti-to-octeti-decline.fab (supporting · reject)#

Decline: bounded ไบต์<N> cannot resize directly to bounded ไบต์<M>.

# =============================================================================
# bounded ไบต์ resize — unsupported แปลง decline
# =============================================================================
#
# What this teaches:
#   • Bounded byte capacities are not interchangeable through an implicit
#     resize route.
#   • The unsupported route fails closed with `SEM016:unsupported_conversio`.
#
# Common mistakes:
#   • expecting a bounded byte แปลง to truncate or pad silently.

fn resize(bytes<8> raw) → bytes<4> {
    return raw ↦ bytes<4>
}

Expected: compilation rejects this example.

radix/corpus/bounded/conversio-octeti-to-textus-decline.fab (supporting · reject)#

Decline: bounded ไบต์<N> cannot convert directly to unbounded ข้อความ.

# =============================================================================
# bounded ไบต์ to ข้อความ — unsupported แปลง decline
# =============================================================================
#
# What this teaches:
#   • A bounded byte carrier does not silently become ข้อความ through `↦`.
#   • The unsupported route fails closed with `SEM016:unsupported_conversio`.
#
# Common mistakes:
#   • assuming byte decoding is the same as a bounded-width สำเนา — decoding
#     needs an explicit ไบต์/textus library route, not this แปลง.

fn widen(bytes<8> raw) → string {
    return raw ↦ string
}

Expected: compilation rejects this example.