If you don't qualify an identifier, its interpretation is determined by the rules of scope described in Blocks and scope.
Extended Identifiers
When programming with Delphi for .NET, you might encounter CLR identifiers (e.g. types, or methods in a class)
having the same name as a Delphi language keyword. For example, a class might have a method called
begin
.
Another example is the CLR class called Type, in the System namespace. Type is a Delphi language keyword, and
cannot be used for an identifier name.
If you qualify the identifier with its full namespace specification, then there is no problem. For example, to use the
Type class, you must use its fully qualified name:
var
TMyType : System.Type; // Using fully qualified namespace
// avoides ambiguity with Delphi language keyword.
As a shorter alternative, Delphi for .NET introduces the ampersand (
&) operator to resolve ambiguities between CLR
identifiers and Delphi language keywords. If you encounter a method or type that is the same name as a Delphi
keyword, you can omit the namespace specification if you prefix the identifier name with an ampersand. For example,
the following code uses the ampersand to disambiguate the CLR Type class from the Delphi keyword type
var
TMyType : &Type; // Prefix with '&' is ok.
Dostları ilə paylaş: