WHAT'S IN THIS CHAPTER?
Understanding modules and namespaces
Defining assemblies in F#
Although it would be nice to imagine that when classes are written they can stand alone, the truth of the modern development environment makes it clear that a class stands among thousands, if not hundreds of thousands, of other classes, and only so many combinations of characters produce meaningful names. For classes to avoid verbose monikers like
OurCompanysGenericLinkedList, some kind of higher packaging and syntactic partitioning system needs to be in place. In the .NET universe, this packaging system is called the assembly, and the syntactic partitioning is the namespace. As a CLR language, F# supports both but also adds a new mechanism from its functional heritage, the module, into the mix.
.NET supports a system of lexical scoping, allowing different types of the same name to be neatly sectioned away from one another, known as namespaces. At its heart, a namespace is just a prefix to the typename, one which can be (usually) avoided in practical use via some kind of namespace-inclusion statement, such as
using in C# or
Imports in Visual Basic. Namespaces have almost no runtime component to them — the CLR references every type internally by its fully qualified name. Namespaces, then, are purely a programmer convenience.
In F# code, to include the list of types in a namespace in the list of top-level accessible names, use the
open keyword followed ...