Modules as Namespaces
A namespace is simply the definition of some set of functionality under one umbrella. You might create a namespace module in situations where you want to provide functionality that can be used without creating objects. For example, the
Abbrev module defines only one method, called
abbrev, which returns a list of possible abbreviations for a set of words (Figure 9.1). This is such a unique and isolated feature that it really doesn’t merit being part of a class and having instances.
Figure 9.1 An example usage of the
abbrev method from the
Of course, you can define methods, variables, and constants outside ...