渲染zh-Hans

公开

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

Marks an import as re-exported from the current module.

Aliases: public

Syntax: 导入 取自 <source> 公开 <name>

Category#

modifier

Examples#

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

Marks an import as re-exported from the current module.

# =============================================================================
# 公开 — Marks an import as re-exported from the current module.
# =============================================================================
#
# What this teaches:
#   • Module export visibility — `@ 公开` (en spelling `@ public`) exports a
#     declaration from the current module, making it importable by any consumer
#   • The opposite of `@ 私有`; controls the public API surface of a module
#   • Unmarked top-level declarations are module-private: only `@ 公开` /
#     `@ 内部` declarations appear in the file's importable surface
#
# Common mistakes:
#   • Leaving a declaration unmarked and expecting it to be importable — the
#     export surface is `@ 公开` / `@ 内部` only.
#
# See also: 私有, 导入
# =============================================================================

# @ 公开 marks a declaration as public metadata
#
# Annotations attach visibility metadata to the following declaration.
#
# GRAMMAR:
#   annotatedDecl :← '@' '公开' funcDecl
#
# EXPECTED OUTPUT:
#   公开

@ public { }
fn publicum() → string {
    return "publica"
}

main {
    print publicum()
}

Expected output:

publica