Skip to content

About this page: this page is editorial guidance written for this documentation site. It summarises and links to source material; it defines no language rules. The normative rules are in the Technical Specification.

Project Structure

This page summarises how programs are organised, using only rules stated in the source material. It defines no new rules.

From Source Code Structure and Syntax, programs are organised into: Projects, Modules, Types, Functions, Contracts, Statements, and Expressions.

From Source File Structure (Section 1), a source file consists of:

  1. Module declaration.
  2. Imports (optional).
  3. Type declarations (optional).
  4. Function declarations.
  5. Other permitted declarations.

From Module and Dependency System:

  • Applications must be separable into independent modules.
  • Every module must declare its public interface; internal details remain private by default.
  • Modules must declare their dependencies; circular dependencies should be rejected by default.
  • Dependencies must be explicitly declared and versioned, with locked versions for builds.

Exact grammar: Section 20: Formal Language Grammar.