渲染zh-Hans

导入

Translation status: 简体中文 reader-locale proof. Term names and code fences follow the zh-Hans pack; supporting prose may still be English.

Imports names from another module or package source.

Aliases: import

Syntax: 导入 取自 <source> [公开] (<name> [作为 <alias>] | * 作为 <alias>)

Category#

package

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!