Modules

This section describes the SDL commands pertaining to modules.

Example

Declare an empty module:

  1. module my_module {}

Declare a module with some content:

  1. module my_module {
  2. type User {
  3. required property name -> str;
  4. }
  5. }

Syntax

Define a module corresponding to the more explicit DDL commands.

  1. module ModuleName "{"
  2. [ schema-declarations ]
  3. ...
  4. "}"

Description

The module block declaration defines a new module similar to the create module command, but it also allows putting the module content as nested declarations:

schema-declarations

Define various schema items that belong to this module.

Unlike create module command, a module block with the same name can appear multiple times in an SDL document. In that case all blocks with the same name are merged into a single module under that name. For example:

  1. module my_module {
  2. abstract type Named {
  3. required property name -> str;
  4. }
  5. }
  6. module my_module {
  7. type User extending Named;
  8. }

The above is equivalent to:

  1. module my_module {
  2. abstract type Named {
  3. required property name -> str;
  4. }
  5. type User extending Named;
  6. }

Typically, in the documentation examples of SDL the module block is omitted and instead its contents are described without assuming which specific module they belong to.

It’s also possible to declare modules implicitly. In this style SDL declaration uses fully-qualified name for the item that is being declared. The module part of the fully-qualified name implies that a module by that name will be automatically created in the schema. The following declaration is equivalent to the previous examples, but it declares module my_module implicitly:

  1. abstract type my_module::Named {
  2. required property name -> str;
  3. }
  4. type my_module::User extending my_module::Named;