The Avail Programming Language

Module Headers

Every module begins with a module header.[1] A module header specifies linkage information that the compiler or executor uses to resolve names mentioned within the module body. Unlike the bulk of an Avail program, which uses an extremely fluid syntax, a module header has a rigid structure that revolves around a small vocabulary of fixed keywords. This rigidity makes it easy and fast for a human or machine reader to understand a module's relationship to upstream modules.[2]

A module header is divided into module header sections (hereinafter "sections"). There are several distinct kinds of section, and every section kind is heralded by a specific keyword. These are the available section kinds:

Keyword Kind Description
Module module name section Declares the name of the module.
Names introduced names section Declares all names introduced and exported by the module.
Entries entry points section Declares all entry points of the module.
Versions active versions section Declares the active versions of the module.
Uses private imports section Declares the private imports of the module.
Extends extended imports section Declares the re-exported imports of the module.
Pragmas pragmas section Gives special directions to the compiler or executor.

With the exception of the module name section, each section kind is optional; it may appear zero or one time. With the exception of the module name section, which must appear first, sections may appear in any order.

A module section ends implicitly at the appearance of another section keyword or the keyword Body. The entire module header ends with the keyword Body, which heralds the beginning of the module body.

[1] A module header may be preceded by whitespace and comments, which are absorbed by the compiler during tokenization. Since tokenization occurs strictly before parsing, it is safe to put comments before the module header. This is nice, because the space before the module header is the best place to put a copyright notice.

[2] It also dramatically simplifies bootstrapping. In general, a module body has no fixed syntax. Allowing the module header this same freedom might make it very difficult to distinguish the module header from the module body, in turn making it very difficult to establish linkage.

‹ Introduction | Return to Modules | Module Name Section ›