ถึง
Translation status: ภาษาไทย reader-locale proof. Term names and code fences follow the th-TH pack; supporting prose may still be English.
A call to a Faber-served route is a typed conversation channel<O, R>: the opener and every reply are checked against the handler.
Syntax: const channel<O, R> s ← call 'prefix:name' (o)
Category#
endpoint
Related#
Examples#
radix/corpus/ad/sermo-conversio.fab (canonical · keyword)#
ถึง opens a ช่องทาง endpoint and materializes the stream with an explicit การแปลง target.
# =============================================================================
# ถึง — ถึง opens a ช่องทาง endpoint and materializes the stream with an explicit
# การแปลง target.
# =============================================================================
#
# What this teaches:
# • Endpoint materialization — `ถึง 'runtime:echo'(payload) ↦ ข้อความ` opens a
# ช่องทาง connection and converts the stream to a concrete type
# • The `↦` materialization operator — directs how the inbound frame stream
# is interpreted
#
# Common mistakes:
# • confusing ถึง route syntax — the materialization target type must match the endpoint's actual return shape
#
# See also: การแปลง
# =============================================================================
# Exemplar: expression `ถึง` with `ช่องทาง ↦ ข้อความ` materialization.
#
# Proves the การแปลง returns the echoed opener text as a `ข้อความ` value.
# The runtime:echo backend echoes the opener back as a single ข้อความ frame;
# `↦ ข้อความ` materializes it. The exemplar asserts equality.
main {
const string t ← call 'runtime:echo' ("salve, munde") ↦ string
assert t ≡ "salve, munde"
}Expected output:
radix/corpus/ad/serve-plain.fab (canonical · annotation)#
@ ถึง serves a route from a Faber function; a caller ads the route and materializes the one reply frame.
# =============================================================================
# ถึง — `@ ถึง '<route>'` serves a route from a Faber function.
# =============================================================================
#
# What this teaches:
# • Serving a route — `@ ถึง 'salutatio:saluta'` registers `saluta` as the
# program's handler for that route; no host is needed for it
# • The caller side is unchanged — `ถึง 'salutatio:saluta' ("munde")` opens a
# ช่องทาง and `↦ ข้อความ` materializes the reply
# • Plain return — a handler that returns one value answers one item frame,
# then done
#
# Common mistakes:
# • giving a handler two parameters — a handler takes zero or one opener;
# pass a ชนิด to send several values
#
# See also: ถึง, ช่องทาง, การแปลง
# =============================================================================
@ ถึง 'salutatio:saluta'
ฟังก์ชัน saluta(ข้อความ ชื่อ) → ข้อความ {
คืน "salve, " + ชื่อ
}
เริ่ม {
คงที่ ข้อความ responsum ← ถึง 'salutatio:saluta' ("munde") ↦ ข้อความ
บันทึก responsum
}Expected output:
salve, munde
radix/corpus/ad/serve-typed.fab (canonical · annotation)#
A call to a Faber-served route is a typed conversation channel<O, R>: the opener and every reply are checked against the handler.
# =============================================================================
# call — a conversation with a Faber handler is typed `channel<O, R>`.
# =============================================================================
#
# What this teaches:
# • Typed conversation — when a Faber function serves the route, `call` has
# type `channel<O, R>`: `O` is the handler's parameter, `R` each item back
# • Inference — `const _ s ← call '…'` infers `channel<O, R>` from the route
# • Dropping the types — a typed channel assigns to a bare `channel`, which
# reads its frames as loose values again
# • No opener — a handler without a parameter has `O = null`, and the call
# passes no opener
#
# Common mistakes:
# • materializing as a type other than `R` or `list<R>` — a compile error
# • passing an opener of the wrong type — the handler's parameter decides
# • a bare `channel` is `channel<value, value>`; host routes stay untyped
#
# See also: ถึง, ช่องทาง, รับ, การแปลง
# =============================================================================
@ call 'numeri:twice'
fn twice(int n) → int {
return n * 2
}
@ call 'salutatio:greeting'
fn greeting() → string {
return "salve"
}
main {
const _ s ← call 'numeri:twice' (21)
const int doubled ← s ↦ int
print doubled
const channel<none, string> g ← call 'salutatio:greeting'
print g ↦ string
const channel<int, int> t ← call 'numeri:twice' (5)
const channel loose ← t
print loose ↦ int
}Expected output:
42
salve
10