匯入
Translation status: 繁體中文 reader-locale proof. Term names and code fences follow the zh-Hant pack; supporting prose may still be English.
Imports names from another module or package source.
Aliases: import
Syntax: 匯入 取自 <source> [公開] (<name> [作為 <alias>] | * 作為 <alias>)
Category#
package
Related#
Examples#
radix/corpus/importa/default-braced.fab (canonical · keyword)#
Canonical braced import record with private binding inferred from the path.
# =============================================================================
# 匯入 — Canonical braced import record with private binding inferred from the path
# =============================================================================
#
# What this teaches:
# • Canonical braced import record with private binding inferred from the path.
# • Related keywords: 取自, 私有, annotation-sugar
#
# Common mistakes:
# • Letting the compiler infer an import name that collides with an existing top-level binding — use `名稱` or `作為` to disambiguate (SEM005).
#
# See also: 取自, 私有, annotation-sugar
# =============================================================================
# 匯入 — canonical braced record
#
# The canonical record spells the source field and lets visibility/name defaults
# materialize the same ImportDecl as `匯入 取自 "norma:text"`.
import { 取自 = "norma:text" }
print "importa-braced"radix/corpus/importa/importa.fab (canonical · keyword)#
Imports names from another module or package source.
# =============================================================================
# 匯入 — Imports names from another module or package source
# =============================================================================
#
# What this teaches:
# • Imports names from another module or package source.
# • Related keywords: 取自, 公開, 作為
#
# Common mistakes:
# • Missing the `取自` source in the import record — an import record requires an `取自` source path.
#
# See also: 取自, 公開, 作為
# =============================================================================
# 匯入 取自 — named import from a sibling module
#
# 匯入 取自 relative path; an absent marker does not re-export.
#
# GRAMMAR:
# 匯入 取自 "<path>" <name> [作為 <alias>]
# 匯入 取自 "<path>" 公開 <name> (re-export)
#
# Requires module layout: 匯入/importa.fab imports from 匯入/auxilium.fab.
# Harness compiles single files in isolation — sibling resolution needs package
# or module mode (faber check --package), not bare single-file emit.
#
# EXPECTED OUTPUT:
# "Salve, Marcus!" on successful link.
#
# BACKEND: Rust/Go e2e whitelist — single-file compile cannot resolve sibling.
import from "./auxilium" auxilium
main {
print auxilium.saluta("Marcus")
}Expected output:
Salve, Marcus!