Static type-name syntax and naming conflicts
- Last Updated: March 30, 2020
- 2 minute read
- OpenEdge
- Version 12.2
- Documentation
The following situations involving static type-name syntax can result in name conflicts that cause unexpected behavior or compiler errors:
-
Naming a variable the same as a class — ABL allows you
to have both a class and a variable defined with the same name.
This is true even for an object-reference variable that is defined
as the given class. However, because variable references take precedence
over static type-name references, this can result in hiding static
references with unexpected effects. For example, if you have a class,
clsName, and define a variable,clsName, any attempt to reference public members of theclsNameclass raises a compile-time error, because ABL identifies all references toclsNameas a variable. Therefore, Progress Software Corporation recommends that you do not name any locally scoped data elements (be they variables, temp-tables, buffers, etc.) the same as a class name. -
Type-names used with qualified table field names — In addition
to hiding static type name references, variable references hide table
field references, and temp-table buffer references hide database buffer
references. Because the syntax for many of these references are
the same, having identical names for these different references
can cause naming conflicts. For example, the following references
will result in compile-time errors if you are connected to the
Sports2000database and you try to reference the staticMaxValueproperty on a class type with same syntactic naming as a reference to the:Customer.Namefield as a staticCustomer.Name:MaxValuereferenceSports2000.Customerbuffer as a staticSports2000.Customer:MaxValuereferenceSports2000.Customer.Namefield as a staticSports2000.Customer.Name:MaxValuereference
Note that a class type name with three or more dots (
.), such asSports2000.Customer.Name.Security, can never be ambiguous with a database reference, because no database reference can contain more than two dots. Therefore, Progress Software Corporation recommends that you do not use package and class names that might result in type-name references that are syntactically identical to the possible qualified temp-table or database buffer and field references. You can also avoid such ambiguities by ensuring that type names contain a minimum of three dots (.) and that you always use fully qualified type names for static type-name syntax references. - Type-names for classes named as reserved keywords — ABL allows a class to have the name of a reserved keyword. However, ABL does not fully support the use of static type-name syntax for classes whose names are reserved keywords. You can work around this limitation by using a package name to qualify any class whose name is a reserved keyword.