Definition module 2026-11-05
A definition module declares the exported interface of a Modula-2 module. It tells clients which names and data types they can use, while the implementation module supplies procedure bodies and private details. The boundary supports separate compilation and programming abstraction.
For example, a stack interface can declare an abstract stack type and push/pop operations without exposing whether storage uses an array or a linked list. Clients should preserve the declared contract rather than inspecting hidden representation. GNU Modula-2 conventionally stores a definition module in a .def file and parses it when compiling importing modules; it does not compile the definition module separately as executable code.[ref]
Implementation module 2026-11-05
An implementation module supplies the executable procedures and private declarations behind a Modula-2 module interface. Its associated definition module determines which declarations clients may import. This separation lets clients depend on an interface while the implementation selects a representation.
For example, a counter module can export a procedure Next while storing a private running count. Its implementation module defines how Next updates and returns that count; clients need not know the private variable's name. Replacing the storage mechanism is possible when the exported behavior remains compatible. The GNU Modula-2 manual illustrates separate definition and implementation source files, then compiles implementation modules before linking them into a software library.[ref]
Modula-2 2026-11-05
Modula-2 is a systems programming language designed by Niklaus Wirth, combining structured programming with explicit software modules and facilities for low-level system construction. A definition module declares an exported interface; an implementation module supplies its implementation and private details. Clients import the declared names instead of depending on every declaration in the implementation.
For example, a stack module can export a stack type and push/pop procedures while keeping the array or linked representation private. This permits separate compilation against an interface and replacement of the implementation when its contract is preserved. Wirth's project account places Modula-2 in the Lilith workstation effort and records completion of its first compiler at ETH in1979.[ref] Low-level facilities make hardware-oriented programs expressible, but also require care about the assumptions connecting language operations to devices and machine representations.