How to pass structured records as individual fields

You can set an EGL property so that a structured record is sent to a called program and received there in any of multiple ways: as a structured record, or as if the record were a set of individual fields that correspond to the leaf elements in that record, or as a sequential set of records and fields. The usage is especially appropriate when EGL-coded logic is interacting with EGL-coded logic that was migrated from code written in the Natural programming language.

The behavior relies on your setting the callingConvention property on both the call statement and the called program. The property value is either CallingConventionKind.Expanded or the short form, Expanded.

For example, consider the following Record parts:
Record MyCompletePart type BasicRecord
   10 myInt INT;
   10 myInt02 INT;
   10 myChars CHAR(5);   
end

Record MySubPart type BasicRecord
   10 myInt02 INT;
   10 myChars CHAR(5);
end
A set of declarations might be as follows:
myCompleteRecord MyCompletePart;
mySubRecord MySubPart;
myIntVar   INT;
myInt02Var INT;
myCharsVar CHAR(5);
The following call statements are valid and equivalent:
call MyProgram( myCompleteRecord )                { callingConvention=Expanded };
call MyProgram( myIntVar, mySubRecord )           { callingConvention=Expanded }; 
call MyProgram( myIntVar, myInt02Var, myCharsVar) { callingConvention=Expanded }; 
The following definitions of MyProgram are valid and equivalent:
Program MyProgram  type BasicProgram ( myCompleteRecord MyCompletePart )
   { callingConvention=Expanded }
   
end

Program MyProgram type BasicProgram ( myIntVar INT, mySubRecord MySubPart ) 
   { callingConvention=Expanded }
   
end

Program MyProgram type BasicProgram ( myIntVar INT, myInt02Var INT, myCharsVar CHAR(5))
   { callingConvention=Expanded }
   
end

Any of the three call-statement argument lists is valid for any of the three called-program parameter lists.

In a subset of cases, the use of Expanded causes the call to take longer than would be the case if you did not use Expanded. For example, consider a record that is based on the following Record part:
Record X type BasicRecord
	10 myChar CHAR(4)[2];
		20 mySubChar01 char(2);
		20 mySubChar02 char(2);
end

When you use Expanded, each leaf (mySubChar01 or mySubChar02) is passed in a contiguous block of memory even though the fields in that leaf are not stored contiguously. The data must be copied, and the extra processing takes time. For details on how multidimensional structure field arrays are stored, see “Arrays.”

In general, the performance issue occurs in the following case:

If you are passing a structure field array explicitly, see “How to pass structure field arrays.”


Feedback