Statements

This document is a living document and may not represent the current implementation of Flux. Any section that is not currently implemented is commented with a [IMPL#XXX] where XXX is an issue number tracking discussion and progress towards implementation.

A statement controls execution.

  1. Statement = OptionAssignment
  2. | BuiltinStatement
  3. | VariableAssignment
  4. | ReturnStatement
  5. | ExpressionStatement .

Import declaration

  1. ImportDeclaration = "import" [identifier] string_lit .

A package name and an import path is associated with every package. The import statement takes a package’s import path and brings all of the identifiers defined in that package into the current scope under a namespace. The import statement defines the namespace through which to access the imported identifiers. By default the identifier of this namespace is the package name unless otherwise specified. For example, given a variable x declared in package foo, importing foo and referencing x would look like this:

  1. import "import/path/to/package/foo"
  2. foo.x

Or this:

  1. import bar "import/path/to/package/foo"
  2. bar.x

A package’s import path is always absolute. A package may reassign a new value to an option identifier declared in one of its imported packages. A package cannot access nor modify the identifiers belonging to the imported packages of its imported packages. Every statement contained in an imported package is evaluated.

Return statements

A terminating statement prevents execution of all statements that appear after it in the same block. A return statement is a terminating statement.

  1. ReturnStatement = "return" Expression .

Expression statements

An expression statement is an expression where the computed value is discarded.

  1. ExpressionStatement = Expression .
Examples of expression statements
  1. 1 + 1
  2. f()
  3. a