The New Module System
STELF’s old module system, outside of standard ML, is quite weak. The new module system is designed to be a true module system, which not only prevents name collisions but also allows for abstractions. There are three main features of the new module system:
- Scopes, which allow name collisions to be avoided
- Macros, which allow for abstraction and code reuse
- Groups, which allow for code to be published as a library
Scopes
Section titled “Scopes”The first of these, scopes, deals with the problem of name collisions.
In the old module system, scopes were mostly done by hand, e.g, add/nat-zero.
While this avoids name collisions, it has a tendency to get long very quickly, for instance, elab_r_exists_app (from the original examples page, )
In the new module system, we instead might write %(add zero nat). Which is shorter and easier to read
Inserting Scopes
Section titled “Inserting Scopes”%scope
%open
%require
Macros
Section titled “Macros”%macro NUM name CMD
%0, %1 etc
%use NAME (ARGS...)
Shorthands
Section titled “Shorthands”%data NAME SORT_ARGS... %where ... -> %sort NAME SORT_ARGS... %. %scope NAME ...