Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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 shader 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_exp brings the names bound in mod_exp into the current scope. They are also re-exported through the enclosing module.

  • local dec binds the names defined by dec in the current scope but hides them from users of the enclosing module.

  • import "foo" is shorthand for local open of the module expression import "foo" (see Modules) — it pulls in another file’s exports without re-exporting them.

  • #[attr] dec attaches an attribute to the declaration it precedes (see Attributes).