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ə38/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   34   35   36   37   38   39   40   41   ...   294
DelphiLanguageGuide

Fully qualified unit names
The following example demonstrates the uses clause with namespaces:
unit MyCompany.Libs.MyUnit1
uses MyCompany.Libs.Unit2,  // Fully qualified name.
     UnitX;                 // Generic name.
Once a module has been brought into context, source code can refer to identifiers within that module either by the
unqualified name, or by the fully qualified name (if necessary, to disambiguate identifiers with the same name in
different units). The following 
writeln
 statements are equivalent:
uses MyCompany.Libs.Unit2;
begin
   writeln(MyCompany.Libs.Unit2.SomeString);
   writeln(SomeString);
end.
A fully qualified identifier must include the full namespace specification. In the preceding example, it would be an
error to refer to 
SomeString
 using only a portion of the namespace:
writeln(Unit2.SomeString);       // ERROR!
writeln(Libs.Unit2.SomeString);  // ERROR!
writeln(MyCompany.Libs.Unit2.SomeString);      // Correct.
writeln(SomeString);                           // Correct.
22


It is also an error to refer to only a portion of a namespace in the uses clause. There is no mechanism to import all
units and symbols in a namespace. The following code does not import all units and symbols in the 
MyCompany
namespace:
uses MyCompany;   // ERROR!
This restriction also applies to the with-do statement. The following will produce a compiler error:
with MyCompany.Libs do    // ERROR!

Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   34   35   36   37   38   39   40   41   ...   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