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

Wastebasket.ImportAggregators History

Hide minor edits - Show changes to markup

2010-01-20 11:50 by benjk -
Added lines 1-35:

The following two approaches to import aggregation were discussed and rejected:

Re-Export by Default

Any module imported by a module might automatically be re-exported.

  • Advantages: No additional syntax required.
  • Disadvantages: Re-export cannot be turned off.

Implicit Re-Export

A definition part which imports one or more modules but exports no items on its own might be deemed to have the purpose of re-exporting all the imported modules ...

DEFINITION MODULE Collections;

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

END Collections.
  • Advantages: No additional syntax required.
  • Disadvantages: Re-export will no longer work if the aggregate module is extended with declarations.

Importing the Aggregator

Importing Collections brings all re-exported modules into scope ...

MODULE UseCollections;

IMPORT Collections;

VAR
    stack : Stack;
...

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

END UseCollections.