containerContextDependent
containerContextDependent 특성은 독립형 함수(함수 참조) 내의 참조가 함수가 생성 후 상주할 컨테이너(기본 파트)와 관련하여 분석되도록 지정합니다. 이는 컨테이너의 선언 및 가져오기가 생성 프로세스 동안 참조를 분석하는 데 사용됨을 의미합니다. 최종 컨테이너가 참조를 분석하기 위해 필요한 모든 패키지를 가져오는 경우에는 최상위 레벨 파트인 경우에도 독립형 함수 자체는 이를 가져오지 않아도 됩니다. 예를 들어, 함수가 둘 이상의 프로그램에서 사용되고 변수 이름이 함수를 호출하는 프로그램에 따라 다르게 분석될 때 이 특성을 사용할 수 있습니다.
독립형 함수에만 containerContextDependent 특성을 사용하십시오. EGL은 VisualAge® Generator에서 작성된 프로그램과 같은 프로그램과의 호환성을 위해 독립형 함수를 지원하며 여기서 언어는 라이브러리를 지원하지 않습니다. 새 코드 작성 시 독립형 함수 또는 containerContextDependent 특성을 사용하지 마십시오.
예제
아래의 첫 번째 코드 세그먼트는 패키지 p에서 제공됩니다.
package p;
Program pgm {includeReferencedFunctions = yes}
function main()
standaloneFunc1();
end
function functionInPgm()
endend
DataItem intInP int end
다음 코드 세그먼트에서 standaloneFunc1()에는
함수를 호출하는 컨테이너의 함수(즉, pgm이라는 컨테이너의
functionInPgm())에 대한 참조와 컨테이너의 파트 범위(즉,
pgm 프로그램과 동일한 패키지 p)에서
분석되는 파트에 대한 참조가 포함되어 있습니다. standaloneFunc2()에서는
containerContextDependent 특성이 독립형 함수에 대해
지정되지 않기 때문에 동일한 참조가 분석되지 않습니다. standaloneFunc3()는
참조에 패키지 이름을 포함하는 경우 containerContextDependent 없이
파트를 계속 참조할 수 있음을 보여줍니다.
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
호환성 고려사항
| 플랫폼 | 문제 |
|---|---|
| JavaScript 생성 | containerContextDependent 특성이 지원되지 않음 |