the structure of programming
play

The Structure of Programming 2. Elementary Program Statements - PDF document

The Structure of Programming 2. Elementary Program Statements Elementary program statements can usually be classified Languages as either commands, requirements or implicit specifications. A command is an imperative statement that commands the


  1. The Structure of Programming 2. Elementary Program Statements Elementary program statements can usually be classified Languages as either commands, requirements or implicit specifications. A command is an imperative statement that commands the action to be taken without saying anything at all about BERTRAM RAPHAEL what effect will thereby be achieved. A requirement de- Stanford Research Institute, Menlo Park, California scribes the effect to be achieved without saying anything at all about the actions to be taken in achieving the effect, nor requiring that the programmer know how the effect In this paper the major components of every programming will be achieved. An implicit specification is similar to a language are identified as: (1) the elementary program state- requirement, but the programmer must know something ment, (2) mechanisms for linking elementary statements together, about what actions will be taken to achieve the desired (3) the means by which a program can obtain data inputs. effect. Several alternative forms of each of these components are also A. Commands. The elementary statements of con- described, compared and evaluated. Many examples, fre- ventional assembly languages are imperative; they com- quently from list processing languages, illustrate the forms mand that certain computations be performed, or that described. data be moved, or that tests be made. Thus, the terminol- The advantages, disadvantages and factors influencing ogy "order code" or "instruction set" is used to refer to the choice of a form of component for a language are dis- the repertoire of operations of a computer. For example, cussed, and the paper concludes with the suggestion that the statement CLA X is manifestly a command. programming languages evolve toward one which will permit In the list processing language IPL-V [1], the elemen- all the most convenient ways of structuring programs, organiz- tary statements are imperatives. They command certain ing systems and referencing data. symbols to be manipulated. For example, the statement 30 W1 is the imperative, "Pop-up the stack cell named 1. Introduction Wi". The way in which a programming language is structured The elementary program statements of most eon- can strongly affect the efficiency and modus operandi of a ventionM programming languages are exclusively com- programmer. The three purposes of this paper are (1) to mands. Recently, languages have emerged whose elemen- identify the major components of programming languages, tary statements are statements of requirements or implicit (2) to describe alternative forms available for imple- specification statements. Programs having such statements menting each of these components, and (3) to compare offer outstanding advantages in many situations. How- and evaluate the various forms. ever, these programs still require the use of commands. The computing community has tried to attach to certain For example, the most natural way to specify when and programming languages such ill-defined labels as impera- under what conditions an input/output operation should tive, declarative and implicit. This paper, while avoiding take place is simply to command it to take place at the discussion of the semantics and applicability of those right time and under the right conditions. Notice the particular terms, attempts to analyze some of the under- roundabout and inelegant mechanisms necessary to lying concepts in the structure and use of a language. handle input/output in languages not having commands: Some form of each of the following components is In LIspl.5 [2], "pseudo-functions" are evaluated for their present in every programming language: an elementary side effects, such as a "print" operation, and their true program statement, a mechanism for linking one elemen- values are ignored; in SNOBOL [3], data can be output only tary program statement to another or to a group of other by the awkward mechanism of requiring it to be part of statements, and a means by which the program can obtain the special string named SYSPOT. data inputs. Several factors, such as the nature of the B. Statements of Requirements. One way of describing a operating system and the kind of problem to be solved, computer 1 is by its transfer characteristics. Data is fed in, influence the relative desirability of various forms of these certain transformations of the data take place and results components of programming languages. In this paper are spewed out. One does not have to give a sequence of the alternative forms for these components are discussed. commands that would carry out the transformation. In- The examples are drawn largely from various languages stead, one may express the transfer function to be executed for symbol manipulation (sometimes called "list processing by the program by presenting only general descriptions of languages"). List languages have been chosen because acceptable data as well as descriptions of the results into list processing is relatively new; none of the forms for which the data are to be transformed. Simon [4] has the components of list languages has as yet been called these descriptions the input and output state de- established as "standard" even in an informal sense. scriptions of the computer. Instead, a variety of interesting languages having different forms are available. Consequently, list languages are a 1 By "computer" is meant the combination of a particular rich source of illustrative material. program running on a particular EDP machine. Volume 9 / Number 2 / February, 1966 Communications of the ACM 67

Recommend


More recommend