Valid and invalid object type name references
- Last Updated: January 16, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
Any object type name that you define or reference must evaluate at compile time to the name and location of a class file. ABL syntax includes several elements where object type names are specified, most of which are described in this book. Although you can specify an object type name with or without surrounding quotes, you cannot use a character variable or character expression to specify the object type, except in specific ABL elements that are verified only at run time.
Assuming appropriate package configurations on PROPATH,
these are examples of valid object type names that you can specify
anywhere an object type name can appear:
|
In this previous example, the reference to {&myClassName} is
a preprocessor directive that is resolved prior to compilation.
These are examples of invalid object type names, where myLocalVariable is
a character variable:
|
In this previous example, the quotes identify elements of a character expression, not an object type name.
These examples of invalid type names illustrate one of the key
aspects of using classes, namely strong typing. In the first example
of an invalid object type name, if a character variable, like myLocalVariable,
is allowed to specify an object type name, the compiler cannot know
the run-time value of myLocalVariable, and thus
cannot verify the physical location of the class file or any references
to the specified class or interface. Similarly, as shown in the
second example of an invalid object type name, because character
literals that are concatenated using the "+" operator
are only evaluated at run time, the compiler cannot assemble an
object type name from a character expression.
DYNAMIC-NEW statement,
take a character expression to specify an object type name. In these
few cases, such object type names are verified only at run time.However, you can combine a preprocessor name with other parts of an object type name, because this combination is evaluated and combined into a single name element at compile time. For example:
|