containerContextDependent

The containerContextDependent property specifies that references inside a standalone function (see Functions) are to be resolved with respect to the container (the generatable part) in which the function ultimately (after generation) resides. This means that the declarations and imports of the container are used to resolve references during the generation process. The standalone function itself, even though a top-level part, does not have to import all the packages that are necessary to resolve references as long as the final container does so. For example, you can use this property when the function is used in more than one program, and variable names are resolved differently depending on the program that calls the function.

Use the containerContextDependent property with standalone functions only. EGL supports standalone functions for compatibility with programs like those created in VisualAge® Generator, where the language does not support libraries. Do not use standalone functions or the containerContextDependent property when writing new code.

Example

The first code segment below is from the package p:
package p;

Program pgm {includeReferencedFunctions = yes}
  function main()
    standaloneFunc1();
  end

  function functionInPgm() 
  end
end

DataItem intInP int end
In the next code segment, standaloneFunc1() contains a reference to a function in the container that invokes the function (that is, to functionInPgm() in the container named pgm), and a reference to a part that is resolved in the part scope of the container (that is, resolved in the same package, p, as the pgm program). In standaloneFunc2(), the same references do not resolve, because the containerContextDependent property is not specified for the standalone function. standaloneFunc3() shows that you can still refer to a part without containerContextDependent, as long as you include the package name in the reference.
package p2;

function standaloneFunc1 { containerContextDependent=yes }
  // reference to function resolves
  // because of containerContextDependent
  functionInPgm();
  
  // reference to part resolves
  // because of containerContextDependent
  myVar intInP;
end

function standaloneFunc2
  functionInPgm();   // reference cannot be resolved
  myVar intInP;      // reference cannot be resolved
end

function standaloneFunc3
  // reference to part resolves because
  // it is qualified by the package name
  myVar p.intInP;
end

Compatibility considerations

Table 1. Compatibility considerations
Platform Issue
JavaScript generation The property containerContextDependent is not supported.

Feedback