Next: Signed Compound Units Up: Units with Signatures Previous: Flattening Signatures

## Signed Units

The `unit/sig` form creates a signed unit: ``

      (unit/sig signature
        (import import-element   )
        renames
        signed-unit-body-expr
          )

      import-element is one of:
         signature
         (identifier : signature)

      renames is either empty or:
         (rename (internal-variable signature-variable)   )

      signed-unit-body-expr is one of:
         (include filename)
         unit-body-expr

The signature immediately following `unit/sig` specifies the export signature of the signed unit. This signature cannot contain sub-signatures. Each element of the signature must have a corresponding variable definition in one of the unit-body-exprs, modulo the optional `rename` clause. If the `rename` clause is present, it maps internal-variables defined in the unit-body-exprs to signature-variables in the export signature.

The import-elements specify imports for the signed unit. The names bound within the signed-unit-body-exprs to imported bindings are constructed by flattening the signatures according to the algorithm in section 7.3.1.1:

- For each import-element using the signature form, the variables in the flattened signature are bound in the signed-unit-body-exprs.
- For each import-element using the `(identifier : signature)` form, the variables in the flattened signature are prefixed with `identifier:` and the prefixed variables are bound in the signed-unit-body-exprs.

Each signed-unit-body-expr is either a regular expression or an `include` form. If a signed-unit-body-expr has the form `(include filename)`, the content of the file named by filename is textually substituted into the `unit/sig` body in the place of the `include` clause. In particular, a single `include` clause can be replaced by any number of expressions from the included file.