[ Modules | Reference Manual | Alphabetic Index ]

# module(+Module)

Begin of the definition of module Module.

Module
  Atom.

## Description

This is a directive that can occur only in a compiled file. If Module is an existing module, it is first erased. Then a new module is created and all subsequent definitions, declarations and directives are taken in the context of that new module.

The new module implicitly imports the module `eclipse_language`, which means that all ECLiPSe built-ins are visible there.

`module(m)` is equivalent to `module(m,[],eclipse_language)`.

Note that module/1 is not a predicate, it can only occur as a directive in a compiled file. However, the console based ECLiPSe toplevel also interprets module/1 commands, but in the following way: when the module already exists, the toplevel-module (i.e. the context in which toplevel queries are interpreted) is changed to this module. When the module does not exist, it gets created and a warning is issued.

The system does not allow the atom [] to be used as a module name!

### Modes and Determinism

- module(+) is det

### Exceptions

(4) instantiation fault
  Module is not instantiated.
(5) type error
  Module is not an atom, or Module is the atom [].
(68) calling an undefined procedure
  When called from Prolog.
(82) trying to access a locked module
  Module is locked.

## Examples

    % A very small module:
         :- module(m).
         :- export hello/0.
         hello :- writeln("Welcome to module m!").

## See Also

module / 1, module / 3, create_module / 1, create_module / 3, erase_module / 1, current_module / 1, export / 1