Unit aliases

Namespaces can become quite long and cumbersome to type. Delphi for .NET allows you to declare a local unit alias to introduce an alias for a long namespace. The following uses clause introduces a local unit alias:

uses MyCompany.AVeryLongNamespaceDesignation.VeryDescriptiveUnitName as aUnit;

Given a unit alias, your source code can refer to an identifier by the shorter name:

// These two statements are equivalent. writeln(aUnit.SomeString);

writeln(MyCompany.AVeryLongNamespaceDesignation.VeryDescriptiveUnitName. SomeString);

Unit aliases must not conflict with other unit or namespace identifiers. Unit aliases introduce Delphi identifiers, and therefore cannot contain dots. A unit alias is local to the unit in which it is declared. A unit alias does not obscure the fully qualified unit name that it aliases; you may always refer to an identifier either by it's fully qualified name, or by a unit alias.

Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook


Post a comment