Declarations
Grammar
dec ::= def_bind | type_bind | mod_bind | mod_type_bind | entry_bind
| "open" mod_exp
| "import" stringlit
| "local" dec
| "#[" attr "]" dec
Description
A Wyn module consists of a sequence of declarations. Declarations are processed in order, and a declaration may refer only to names bound by preceding declarations — forward references are not permitted.
The five binding forms — def_bind, type_bind, mod_bind,
mod_type_bind, and entry_bind — bind values (including functions),
types, modules, module types, and host-visible entry points respectively.
Their syntax is detailed in the sections that follow.
Names bound by a declaration inside a module are visible to users of
the module by default (see Modules); the local modifier suppresses
this.
Declaration Modifiers
-
open mod_expbrings the names bound inmod_expinto the current scope. They are also re-exported through the enclosing module. -
local decbinds the names defined bydecin the current scope but hides them from users of the enclosing module. -
import "foo"is shorthand forlocal openof the module expressionimport "foo"(see Modules) — it pulls in another file’s exports without re-exporting them.
DISCREPANCY: The current compiler does not implement the
localmodifier or apply local-open semantics to plainimport "foo". This visibility work is deferred for the first package manager, which treats every declaration as non-local. The intended behavior remains part of the language and is covered by ignored tests inwyn-core/src/resolve_imports_tests.rs.
#[attr] decattaches an attribute to the declaration it precedes (see Attributes).