Compatibility rules
- Last Updated: March 30, 2020
- 2 minute read
- OpenEdge
- Version 12.2
- Documentation
Compatibility rules
Since an object reference and a procedure handle represent two very different constructs in ABL, the following rules apply when working with both:
- You cannot execute r-code for a class using the
RUNstatement. You must use theNEWfunction to create a class instance. - You can only use the
NEWfunction to create an instance of a class. You cannot use theNEWfunction to run a persistent procedure. - An instance of a class never has a procedure object handle associated with
it. Thus, a class does not use system handles, such as
THIS-PROCEDUREorTARGET-PROCEDURE, that return procedure object handles for referencing the r-code of a referencing procedure. Using any of these keywords in a class results in a compile-time error. - A procedure has no notion of a class or object reference. Thus
a procedure cannot use system references, such as
THIS-OBJECT, that return references to the r-code of a referencing class or class hierarchy. Using any of these keywords in a procedure results in a compile-time error. - You cannot assign a procedure handle to an object reference. You cannot assign an object reference to a procedure handle. Thus, while you can cast object reference types from one to another, you cannot cast an object reference type to a procedure handle or in any way convert one to the other.
- You cannot pass an object reference to a routine expecting a procedure handle. Likewise, you cannot pass a procedure handle to a routine expecting an object reference. As noted, there is no way to cast a procedure handle to an object reference or an object reference to a procedure handle.
- You cannot define methods in a procedure. Procedures define their internal entry points as internal procedures or user-defined functions only. You can define methods only in classes. Likewise, you cannot define internal procedure or user-defined functions in procedures, but only in external procedures.
- You cannot use the
object-reference:method-namesyntax to run an internal procedure or a function, but only a method. You can use this syntax, however, in both classes and procedures. - You cannot define a constructor or destructor for a procedure. You can define these special methods only for classes.
- You cannot specify a
PRIVATE,PACKAGE-PRIVATE,PROTECTED,PACKAGE-PROTECTEDorPUBLICaccess mode on a variable or other data definition except in the main block of a class. - You cannot use the ABL built-in
ADD-SUPER-PROCEDURE( )method on theTHIS-OBJECTsystem reference or theTHIS-PROCEDUREsystem handle within a class or otherwise use the super procedure mechanism to create a hierarchy of object references. Thus, you cannot add a class-based object as a super procedure. However within a class, you can use theSESSION:ADD-SUPER-PROCEDURE( )method to extend the super procedure chain of theSESSIONhandle, and you can use the procedure-handle:ADD-SUPER-PROCEDURE( )method, where procedure-handle is a procedure object handle set from running a persistent procedure, in order to extend the super procedure chain for other, procedure objects.