Chapter 6
PROGRAM MODULES

     SIMULA-source-module
         =  [ external-head ]
            (  program  | procedure-declaration  |  class-declaration )

Program modules constitute compilable programs, procedure declarations, and class declarations.

Example:

      external class b, c;  ! external head of class e;
      b class e(f); ref (c)f;
      begin
         external class d;
         external procedure aproc;
         ref (d) dref;
         dref :- new d;
         aproc(dref);
      end class e;

External declarations

     external-head
         =  external-declaration ;  { external-declaration ; }

     external-declaration
         =  external-procedure-declaration  |  external-class-declaration

An external declaration is a substitute for a complete introduction of the corresponding source module referred to, including its external head. In the case where multiple but identical external declarations occur as a consequence of this rule, this declaration will be incorporated only once.

Note: An uncommitted occurrence of a standard identifier within a source module refers to the declaration of that identifier within the class ENVIRONMENT or BASICIO, implicitly enclosing the main program (see chapters 9 and 10), with the exception of class identifiers (see 5.5.1).
If a class identifier is referenced before the body of a separately compiled procedure or class declaration, or in a program block prefix, then this identifier must be declared in the external head.

The main program

     program
         =  statement

The statement of the main program is implicitly enclosed in a prefixed block as described in chapter 10.

External procedure declaration

     external-procedure-declaration
         =  external  [ kind ]  [ type ]  procedure  external-list
         |  external kind procedure external-item procedure-specification

     kind
         =  identifier

     procedure-specification
         =  is  procedure-declaration

The kind of an external procedure declaration may indicate the source language in which the separately compiled procedure is written (e.g assembly, Cobol, Fortran, PL1 etc.). The kind must be empty if this language is Simula. The interpretation of kind (if given) is implementation-dependent.

If an external procedure declaration contains a procedure specification, the procedure body of the procedure declaration must be empty. This specifies a procedure whose actual body, which embodies the algorithm required, is supplied in a separate (non-Simula) module. The procedure heading of the procedure declaration will determine the procedure identifier (function designator) to be used within the source module in which the external declaration occurs, as well as the type, order, and transmission mode of the parameters.

A non-Simula procedure cannot be used as an actual parameter corresponding to a formal procedure.

External class declaration

     external-class-declaration
         =  external  class  external-list

An implementation may restrict the number of block levels at which an external class declaration may occur.

Note: As a consequence of 5.5.1 all classes belonging to the prefix chain of a separately compiled class must be declared in the same block as this class. However, this need not be done explicitly; an external declaration of a separately compiled class implicitly declares all classes in its prefix chain (since these will be declared in the external head of the class in question).

Module identification

     external-list
         =  external-item  { , external-item }

     external-item
         =  identifier  [ = external-identification ]

     external-identification
         =  string

The identifier of an external item must be identical to the identifier of the corresponding separately compiled class or Simula procedure.

An external item may introduce an external identification to identify the separately compiled module with respect to the environment. The interpretation of the external identification string is implementation-dependent, as is the identification of the module in question in case no external identification is given.