Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

Transparently substitute module with package

Version 1
Created 2012-03-30
StatusDraft
Last modified 2012-03-30
Author Andrei Alexandrescu

Abstract

This proposal allows a module to be replaced with a package, without requiring changes to client code. It solves the problem of modules growing too large to be conveniently managed as one file, yet with an interface small enough. After the substitution users may continue using the same import statement to use the package, or may import only parts of it.

Rationale

This is a “growing pains” kind of issue. Some modules in std (algorithm, datetime) have grown large, which makes it difficult to manage them as single files. Other libraries may be experiencing the same issue. This proposal allows breaking a module into a package without breaking client code that assumes the code is still in one module.

Description

This proposal comes with an important lookup rules change. When looking up the symbol “foo.bar.baz”, currently an exact match is needed. However. when looking up “.baz” or simply “baz”, a flexible lookup is used that has many advantages (less verbose, hijacking detection etc). Therefore we think similar flexibility should be imparted to “foo.bar.baz”, as follows:

Usage

No particular usage notes beyond the above.

This document has been placed in the Public Domain.