Modula-2 Reloaded

A Modern Typesafe & Literate Programming Notation

Site Menu

Project

Specification

Implementation

Recommendations

Reference

Needs Updating

Work in Progress

Wastebasket

Wiki Manual

edit SideBar

Import Aggregators

In both PIM and ISO Modula-2, imported identifiers may be re-exported by including them in a CONST declaration ...

DEFINITION MODULE ReExporter;

IMPORT OriginalExporter;
CONST Foo = OriginalExporter.Foo;  (* re-export as ReExporter.Foo *)

END ReExporter.

However, there is no instrument to re-export identifiers without rebranding them. The ability to re-export a group of modules is desirable to allow the import of a library that consists of multiple modules using a single module identifier for the entire library.

The following approach to import aggregation has been selected for adoption into the language:

Explicit Re-Export

To re-export an imported module, it may be marked with a re-export marker, a trailing plus ...

DEFINITION MODULE Collections;

IMPORT CollectionStatus, Stack+, Queue+, BinarySearchTree+, Trie+, HashTable+, DynamicArray+;

(* CONST, VAR, TYPE, PROCEDURE declarations *)

CONST Status = CollectionStatus.Status; (* re-export as Collections.Status *)

END Collections.

Advantages: Re-export is clearly visible and fully under library control. Allows combination of re-export and rebranded export.

Importing the Aggregator

Importing Collections would then bring all re-exported modules into scope ...

MODULE UseCollections;

IMPORT Collections;

VAR
    stack : Stack;
    status : Collections.Status;
...

stack := Stack.New(size, status);
...

END UseCollections.