What is the scope of COBOL?

How is COBOL defined? Is it static?

+4
source share
3 answers

Cobol has compile-time binding for variables, sometimes called static scope.

Inside this, Cobol supports several levels of visibility in programs:

  • "External" variables are the equivalent of a common Fortran or assembler section; they are truly global.

  • The variables "Global program area" declared in the working repository as global are visible for the entire program in which they are declared and in all nested subprograms contained in this program.

  • Program Scope variables declared in the working repository are visible to the entire program in which they are declared.

  • Program Scope variables declared in local storage are visible to the entire program in which they are declared, but are deleted and reinitialized with each call. Think of an area sorted by sections.

  • The "nested program area" Cobol does not distinguish between programs and functions / procedures; its equivalence of a procedure or function is called a program. A program can contain an infinite number of programs, and the variables of each of them are visible only within the limits of this separate program. You can consider this as an area of ​​functions / procedures.

The OO extensions that many vendors have, and the 2002 standard, define the traditional scope and scope of a public / protected / private object.

Cobol is as old as Radar, Laser and Scuba, can we stop cutting it?

+4
source

All variables in the COBOL program are global. Actually, there are no "areas" (in traditional COBOL, I did not bother with OO extensions), but simply "modules" or "programs".

Intermodular communication is carried out through the Linkage section (usually passed using ref), as well as all the variables that are visible from the called module.

0
source

COBOL uses a static (lexical) scope (like C, C ++, Java, and Pascal). Dynamic reach is not very common in the programming world. I think some versions of Lisp and SNOBOL used a dynamic scope.

If you are interested in understanding the field of knowledge regarding programming languages, you should consider this document.

0
source

Source: https://habr.com/ru/post/1340670/


All Articles