The implementation is the private portion of a module. Implementation
files have the name of the module with an .m3
extension, and have
the following format:
MODULE <module-name> [ EXPORTS <interface> { "," <interface> ... } ]; {Imports} (* See section Imports *) {Declarations} (* See section Declarations *) BEGIN (* Optional Module startup code; BEGIN required *) END <module-name>.
Generally, <module-name> is the same as the name of the interface being implemented, but if not, the EXPORTS clause can be used to specify which interface(s) are being implemented.
Here is an example of an implementation file MyModule.m3 that implements MyModule:
MODULE MyModule; IMPORT IO; PROCEDURE PrintThing(READONLY r: Thing) = BEGIN IO.Put(r.name&"\t"); IO.PutInt(r.size); IO.Put("\n"); END PrintThing; PROCEDURE MakeThing(n: TEXT; s: INTEGER): Thing = BEGIN RETURN Thing{n, s}; END MakeThing; END MyModule.