next up previous index
Next: Use clauses Up: Managing the modularity Previous: Managing the modularity

Purpose

The purpose of modularity is double:

A reusable module is defined by a MODULE clause in the header, as in:

MODULE MyUtils;

  PROCEDURE MultStr(What, By);
    BEGIN
    RESULT := "";
    FOR i := 1 TO By DO
      RESULT := RESULT & What;
      END;
    END MultStr;

Then, one can use the facilities provided by this module by means of a USE clause:

USE MyUtils;

PROCEDURE INIT;
  BEGIN
  OUT.WriteLn (MyUtils.MultStr ("Hello !", 5));
  END INIT;

The clause USE MyUtils defines a read-only variable named ``MyUtils'', and the procedures, variables and constants defined in the MyUtils module can be used by using the connection operator (``.'').