How You Can Enhance Performance When Declaring Reference Variables
Because OpenROAD automatically creates an object of the specified class when you declare the reference variable without specifying that it defaults to null, you can enhance performance by specifying the null default in the following circumstances:
• Declaring reference variables as parameters
If you declare a reference variable as a parameter and do not specify that it default to null, an instance of the object is allocated in the called frame or procedure even if no argument of that type is passed to the child.
If an object is passed as an argument, the implicitly created object is overridden by the explicitly passed object. The time spent creating and removing the implicit object can be avoided by declaring each reference variable with default null.
• Declaring local variables
Similarly, you can avoid an implicit allocation and variable removal in local variable declarations by specifying default null.
Specify this clause when creating a variable that is used to reference an object, as opposed to creating an instance of the object. In the 4GL code you can do one of the following:
– Point this reference variable to an existing object of the same type.
Assume that subfrm.customer.address is an entry field that is referenced throughout a long script. To enhance performance when working with such a deeply nested attribute, you can point a second reference variable to it. You can then use the second variable as an abbreviation for the first, for example:
declare
ef1 = EntryField default null; /* instance
not required */
enddeclare
...
ef1 = field(subfrm.customer.address);
– Create an object of the same type. If you create a reference variable for an object that does not exist and you set its default to null, you must explicitly create the object before you can reference it, for example:
Declare
ef2 = EntryField default null; /* instance
not required */
enddeclare
...
ef2 = EntryField.Create( );
Note: If you do not declare a variable with default null, you do not need to create its object explicitly. For examples of explicit object creation, see
Creating Dynamic Frames.
Last modified date: 12/20/2023