1.5.2 The Concept of "Undefined"

One of the fundamental concepts of the FORTRAN standard is the concept of "undefined." This is one of the most important concept, yet one of the most difficult to comprehend. Anyone who has studied FORTRAN has probably encountered the following sentence in a grammar book and has been puzzled by it.

When xx, variable yy is undefined.
At first glance, this may seem to mean that "a random number is assigned to yy," or that "the value is erased from memory," but that is not what this means. In most cases, the compiler is certain about what happens to yy in case of xx .

To understand this rather puzzling sentence, you need to consider who the documents of FORTRAN standard were written for. The FORTRAN standard is a document written for us programmers as well as for those who create the FORTRAN compilers. Therefore, this sentence was written so that it can be translated in two ways. For those who create compilers, the above sentence translates to

When xx, the memory area occupied by variable yy may be used.
To us programmers, this translates to
Since those creating compiler were told the above, what happens to yy is undefined.


If this sentence is taken as a message from "those who created" the compiler to "those who use" compilers, many will no doubt be indignant that "the creator should be so  irresponsible that he doesn't know what happens!" Especially, one gets such an impression upon reading the grammar book that comes with the compiler. But keep in mind that a FORTRAN grammar book contains 

 rules for clarifying the responsibilities of both parties, those who create compilers and those who use them.



The opposite of "undefined" is "defined," a state in which the value is guaranteed by the standard. According to standard, variables that can be inquired in programs are limited to those "defined." A variable becomes "undefined" in the following cases.