Delphi Language Guide Delphi for Microsoft Win32 Delphi for the Microsoft. Net framework



Yüklə 0,84 Mb.
Pdf görüntüsü
səhifə40/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   36   37   38   39   40   41   42   43   ...   294
DelphiLanguageGuide

Multi-unit Namespaces
Multiple units can be grouped together into one namespace using an extension of the in clause in the project source
file. The file name string can list multiple unit source files in a semicolon-delimited list.
uses
  MyProgram.MyNamespace in 'filepath/unit1.pas;otherpath/unit2.pas';
In this example, the namespace 
MyProgram.MyNamespace
 logically contains all the interface symbols from
unit1
 and 
unit2
.
Symbol names in a namespace must be unique, across all units in the namespace. In the example above, if
unit1
 and 
unit2
 both define a global interface symbol named 
mySymbol
, the compiler will report an error in the
uses clause.
You use a multi-unit namespace by specifying the namespace in the uses clause of a source file. Source code that
uses a multi-unit namespace implicitly uses all the units listed as being members of that namespace.
All the units defined by the current project as members of that namespace will be available to the compiler for symbol
lookup while compiling that source file.
The individual units aggregated in a namespace are not available to source code unless the individual units are
explicitly used in the file's uses clause. In other words, if a source file uses only the namespace, then fully qualified
identifier expressions referring to a symbol in a unit in that namespace must use the namespace name, not the actual
unit that defines that symbol.
A uses clause may refer to a namespace as well as individual units within that namespace. In this case, a fully
qualified expression referring to a symbol from a specific unit listed in the uses clause may be referred to using the
actual unit name or the namespace for the qualifier. The two forms of reference are identical and refer to the same
symbol.
23


Note:
Since unit identifiers are not emitted to .NET assembly metadata, explicitly using the unit in the uses clause
will only work when you are compiling from source or dcu files. If the namespace units are compiled into an
assembly and the assembly is referenced by the project instead of the individual units, then the source code
that explicitly refers to a unit in the namespace will fail because that unit name does not exist in the metadata
of the assembly.
24



Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   36   37   38   39   40   41   42   43   ...   294




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin