Imports
The common sugar form is:
import from "<source>" <name>Import this name from this source. Imports do not re-export by default; use
public when the imported name should be visible to consumers of your module.
The retired private import marker is not valid.
From the standard library#
Norma modules are named norma:<module>.
faber convert --to en — English reader surfaceimport from "norma:consolum" consolum
main {
print "ready"
}faber convert --to la — canonical Faberimporta ex "norma:consolum" consolum
incipit {
nota "ready"
}faber convert --to th-TH — Thaiนำเข้า ออก "norma:consolum" consolum
เริ่ม {
บันทึก "ready"
}faber convert --to zh-Hans — Simplified Chinese导入 取自 "norma:consolum" consolum
入口 {
显示 "ready"
}faber convert --to zh-Hant — Traditional Chinese匯入 取自 "norma:consolum" consolum
入口 {
註記 "ready"
}faber convert --to vi — Vietnamesenhập từ "norma:consolum" consolum
bắt_đầu {
ghi_chú "ready"
}faber convert --to ar — Arabicاستورد من "norma:consolum" consolum
بداية {
اعرض "ready"
}faber convert --to hi — Hindiआयात सेवन "norma:consolum" consolum
आरंभ {
दिखाओ "ready"
}From a local file#
A relative path imports a sibling module. No extension.
faber convert --to en — English reader surfaceimport from "./auxilium" saluta
main {
print "ready"
}faber convert --to la — canonical Faberimporta ex "./auxilium" saluta
incipit {
nota "ready"
}faber convert --to th-TH — Thaiนำเข้า ออก "./auxilium" saluta
เริ่ม {
บันทึก "ready"
}faber convert --to zh-Hans — Simplified Chinese导入 取自 "./auxilium" saluta
入口 {
显示 "ready"
}faber convert --to zh-Hant — Traditional Chinese匯入 取自 "./auxilium" saluta
入口 {
註記 "ready"
}faber convert --to vi — Vietnamesenhập từ "./auxilium" saluta
bắt_đầu {
ghi_chú "ready"
}faber convert --to ar — Arabicاستورد من "./auxilium" saluta
بداية {
اعرض "ready"
}faber convert --to hi — Hindiआयात सेवन "./auxilium" saluta
आरंभ {
दिखाओ "ready"
}Importing a specific item#
The name after the source is the item, not the module — so you import exactly what you use.
import from "norma:textus" string
main {
print "ready"
}Aliasing#
as renames on the way in.
faber convert --to en — English reader surfaceimport from "./auxilium" saluta as greet
main {
print "ready"
}faber convert --to la — canonical Faberimporta ex "./auxilium" saluta ut greet
incipit {
nota "ready"
}faber convert --to th-TH — Thaiนำเข้า ออก "./auxilium" saluta ในชื่อ greet
เริ่ม {
บันทึก "ready"
}faber convert --to zh-Hans — Simplified Chinese导入 取自 "./auxilium" saluta 作为 greet
入口 {
显示 "ready"
}faber convert --to zh-Hant — Traditional Chinese匯入 取自 "./auxilium" saluta 作為 greet
入口 {
註記 "ready"
}faber convert --to vi — Vietnamesenhập từ "./auxilium" saluta như greet
bắt_đầu {
ghi_chú "ready"
}faber convert --to ar — Arabicاستورد من "./auxilium" saluta كـ greet
بداية {
اعرض "ready"
}faber convert --to hi — Hindiआयात सेवन "./auxilium" saluta रूपमें greet
आरंभ {
दिखाओ "ready"
}Useful when two modules export the same name, or when the original reads badly at the call site.
Re-exporting#
public imports and re-exports, so consumers of your module see the name
too. Imports without it remain private to the current module.
import from "norma:textus" public string
main {
print "ready"
}Use public only when you deliberately intend to widen your module's surface.
At a glance#
| Form | Effect |
|---|---|
import from "norma:consolum" consolum | Standard library module |
import from "./auxilium" saluta | Item from a sibling file |
import from "./auxilium" saluta as greet | …bound under a different name |
import from "norma:textus" public string | Imported and re-exported |
Related: A program is a package for how modules let inside a package · Packages with Cista for dependency resolution