USING statements and their order

Posted by mstassen on 17-Mar-2014 03:14

What will happen in the next situation

There is a Zclass.cls in package X and in package Y (Zclass in Y inherits form Zclass in X)

In my code i have

USING X.*.

USING Y.*.

MyClass = NEW ZClass().

 

Which class wil be Myclass? The one from package X or package Y ? And why ? Is the order of USING important ?

 

I have read the documentation about this but i cannot get it:

During procedure or class definition file compilation, ABL resolves all unqualified type name references according to the following algorithm:
a)
ABL examines the USING statements in order and, for each statement that specifies a object-type-name, compares the unqualified name with the last node of the object-type-name. If the names are equal, ABL considers this a match and continues compilation with the current USING statement according to its specified FROM option:
*
If FROM ASSEMBLY is specified, ABL searches for object-type-name in the loaded assemblies.
*
If FROM PROPATH is specified, ABL checks if object-type-name specifies a built-in class or interface type, and if not, ABL searches for a corresponding class file according to the object-type-name package relative to PROPATH.
*
If no FROM option is specified, ABL checks if object-type-name specifies built-in class or interface type, and if not, ABL first searches for a corresponding class file according to the object-type-name package relative to PROPATH, then searches for object-type-name in the loaded assemblies.
b)
If ABL has not matched the unqualified type name with a object-type-name specified in a USING statement, ABL again examines the USING statements in order. For each USING statement that contains a package-name.* or namespace.*, ABL replaces the “*” with the unqualified name, creating a object-type-name. ABL then continues compilation with the current USING statement according to its FROM option:
*
If FROM ASSEMBLY is specified, ABL searches for object-type-name in the loaded assemblies.
*
If FROM PROPATH is specified, ABL checks if object-type-name specifies a built-in class or interface type, and if not, ABL searches for a corresponding class file according to the object-type-name package relative to PROPATH.
*
If no FROM option is specified, ABL checks if object-type-name specifies built-in class or interface type, and if not, ABL first searches for a corresponding class file according to the object-type-name package relative to PROPATH, then searches for object-type-name in the loaded assemblies.
c)
If ABL does not identify a qualified type name from any object-type-name derived from a USING statement, it searches for the unqualified type name reference as a complete ABL type name (defined without a package-name). Thus, ABL searches for an ABL class file with a filename equal to the unqualified type name directly on PROPATH.
If none of these searches identify a valid type definition, ABL generates a compiler error that the type cannot be found.

 

 

 

 

 

All Replies

Posted by mstassen on 17-Mar-2014 05:06

some more specific: i want to be able to trust the using statement order to find the right class !

file and directory structure:

Src/Datamex/Progress/CRM/UI/UIInputBox.cls

Src/Datamex/Progress/DORA/UI/UIInputBox.cls

Src/Datamex/Progress/Trade/UI/UIInputBox.cls

PROPATH is Src.

code:

USING Datamex.Progress.Trade.UI.*.

USING Datamex.Progress.Crm.UI.*.

USING Datamex.Progress.DORA.UI.*.

DEF VAR clsTest AS UIInputBox.

clsTest = NEW UIInputBox("1", "2", "3", "4", "5") .

MESSAGE "VERSION:" clsTest:ToString() VIEW-AS ALERT-BOX INFO.

Is this the right way; does Progress look for classes in the USING statement order ?

Posted by Evan Bleicher on 17-Mar-2014 07:27

The Compiler looks for classes in the USING statement order with the caveats noted below:

The following steps are taken by the Compiler to resolve an unqualified type name:

• Compare the unqualified name against the last node of each <type-name> specified in a USING statement in the order of the USING statements.  If the names are equal, we have a match.  The compiler then checks to make sure the type exists on PROPATH.  If it doesn’t, there is an error.

• If not yet resolved, replace the “*” of each package.*, in the order of the USING statements, with the unqualified name.  Check the resulting partially qualified file name to see if type exists on PROPATH.  If so, we have a match.

Posted by Thomas Mercer-Hursh on 17-Mar-2014 10:36

If you have source code for the modules in question, there would be a ***lot*** to be said for *not* using a naming convention that fostered this kind of potential confusion.  It assumes a ***lot*** on the part of the reader.

This thread is closed