Namespaces

The program structure in the Fore.NET language is organized using namespaces.

Each unit with program text consists of the following blocks (in the specified order):

  1. Zero or more Imports directives.

  2. Zero or more global attributes.

  3. Zero or more declarations of namespaces and namespace members.

All blocks of all units, which an assembly consists of, are included into a common declaration space named global namespace.

The Imports directives facilitate the use of namespaces and types determined in other namespaces and affect the name resolution process during compilation.The Imports directive imports types contained in the specified namespace that enables the use of unqualified identifiers when referring to types. Import is executed only from the specified namespace without import of types from nested namespaces. If an imported namespace contains a member with the same name as a name declared within the current code or namespace body, the locally declared name has priority over the imported one.

A namespace declaration consists of the Namespace keyword, followed by a namespace name and body, ended with a sequence of End Namespace keywords.

A namespace can be declared at the level of a global namespace or within another namespace. In both cases the namespace name must be unique within the enclosing namespace. A namespace allows for declaring any types available in Fore.NET.

Namespaces have public access level and their declarations cannot contain access modifiers.

Optional Imports directives in a namespace body import names of other namespaces and types, allowing them to be referenced directly instead of through qualified identifiers.

Namespaces are extended if two namespace declarations with the same fully qualified names are added to the same declaration space.

Example

Imports System;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Ui;

[Assembly(AssemblyTitle("Test application"))]
[Assembly(AssemblyCompanyAttribute("Any Company"))]
[Assembly(AssemblyVersion("1.0.0.0"))]

Namespace UserApplication
    Var
        s: string;
        i: integer;
    Const
        e = 0.0001;
    //Declaration of types and type members
    //organizing the code of the custom application
End Namespace;

See also:

Fore.NET Language Guide