Skip to main content
Top

1978 | Book

Fortran, PL/I and the Algols

Author: Brian Meek

Publisher: Macmillan Education UK

Book Series : Computer Science Series

insite
SEARCH

Table of Contents

Frontmatter

Prelude

Prelude
Abstract
Most people do not choose which programming language to learn first — the choice is made for them, by an employer, a teacher, or the provider of the computer system available. Some never get past that first language, because they do not have the opportunity, or because they do not have the need, or because they do not perceive the need. Yet any programmer (or computer user who writes programs but who does not think of himself as a programmer) who raises his head from his coding sheet and looks about him, cannot fail to be aware that there are very many other languages. Occasionally at least, he must wonder about those languages — whether any of them are worth learning, whether any of them would be better for the program he is writing than the one he is using.
Brian Meek

Fortran and Algol 60

Frontmatter
1.1. Basic Facilities
Abstract
It is as well to begin the discussion of Algol 60 and Fortran by clearing out of the way some notational and other (apparently) superficial differences between the languages. Expert programmers tend to take such things in their stride, and occasionally when languages are compared they are regarded as trivial and unimportant. However, there are a number of reasons why they should not be dismissed too lightly. The expert programmer familiar with the basic concepts of programming can give more of his mind to mastering unfamiliar ways of expressing or using those concepts in a new language than can a newcomer who is still struggling to master the concepts themselves; to the inexperienced programmer questions of notation are very important, and some who have programmed extensively, but in one language only, often associate the notation and the underlying concepts so closely in their minds that they find notational differences very confusing and are often irritated and even offended by them. Then, notation can affect the implementation and use of the language. Perhaps most interestingly from our point of view, choice of notation can have consequences for the structure of a language, and it can shed some light on the approach and attitudes of its designers.
Brian Meek
1.2. Conditional Statements
Abstract
One keyword that appears in all four of the languages under discussion, and many others besides, is ‘if ’. It is arguably the most important keyword, since it expresses the taking of a decision, the conditional execution of some instruction or sequence of instructions.
Brian Meek
1.3. Arrays and Iterations
Abstract
One of the simplest but most important and fundamental data structures is the dimensioned variable or array, consisting of elements each of the same data type. In all the languages we are discussing, arrays can be created and individual elements referred to by the use of subscripts. The common technique is that the array name is followed by the subscript or (if there are more than one) subscripts, enclosed in brackets. The brackets are of course necessary, in all cases, because of the limitation on type founts and the necessity of distinguishing subscripts from the name of the array.
Brian Meek
1.4. Program Structure, Procedures and Subprograms
Abstract
We now come to one of the key differences between Algol 60 and Fortran, one which it is necessary to understand in order to appreciate to the full the differences between the languages in their treatment of procedures or subprograms, and which also helps to explain some of the other differences. This concerns the handling of storage, in particular for user-defined data items like variables and arrays. A shorthand way of describing the difference is that in Fortran storage is static whereas in Algol it is dynamic; but these terms need further explanation.
Brian Meek
1.5. Other Data Types
Abstract
In this chapter data types other than the two basic arithmetic types will be covered. The first section deals with the Boolean (logical) data type, and the second with some additional data types available in Fortran but not in Algol 60.
Brian Meek
1.6. Goto Facilities
Abstract
While, as mentioned earlier, the dangers of goto statements have in recent years become widely recognised and their use tends to be deprecated, they cannot be ignored because they exist in all four languages we are discussing, and in the case of Fortran 66 their extensive use is inevitable. In this chapter the facilities in Algol 60 and Fortran will be briefly reviewed and compared.
Brian Meek
1.7. Other Facilities
Abstract
In this chapter, further facilities of Algol 60 and Fortran will be discussed. For the most part these are facilities which exist in one of the languages and do not have equivalents in the other, or which do not exist in the other languages to be discussed.
Brian Meek

PL/I

Frontmatter
2.1. Basic Facilities
Abstract
In chapter 1.1 we began by presenting a trivial program to add two real numbers.
Brian Meek
2.2. Conditional Statements
Abstract
Conditional statements in PL/I can be most conveniently introduced by direct comparison with those in Algol 60. Notation apart, the same keywords are used: IF, THEN and ELSE. The first two delimit an if clause in the same way
with the condition being specified by an expression yielding a suitable truth value. There are in fact differences in the allowable expressions, arising from the fact that PL/I does not distinguish Boolean values from arithmetic ones in the same way as Algol, but simple relational conditions can be used in much the same way, as in
using the relational operators >, < and = in their Algol sense. PL/I does not have the characters ≥, ≤, or ≠ so instead the standard operators are multiple symbols, thus
and
Alternatively, as mentioned in the last chapter, reserved identifiers may be used for some or all of these in some implementations.
Brian Meek
2.3. Arrays and Iterations
Abstract
Arrays are declared in PL/I using the declare statement as for simple variables. No special keyword is needed; the array and its dimensions and subscript ranges are declared by including a bound specification after the identifier. In the declaration
a one-dimensional array of four elements A1(0), A1(1), A1(2) and A1(3) is declared. Every array element has the same attributes of mode, base, scale and precision — in this case the default attributes. In the declaration\
a two-dimensional array of 5 * 6 = 30 elements is declared, each element being a fixed-point decimal number of default precision. When the lower bound of a subscript range is 1, as in
which is a factored declaration, the lower bound may be omitted, with its colon, it being taken as 1 by default
Brian Meek
2.4. Procedures and Program Structure
Abstract
In the corresponding chapter of part 1 (chapter 1.4) we saw that in Algol 60 blocks and procedures are nested one inside another, storage allocation is dynamic, and store availability and sharing are organised by the common access of all blocks and procedures to the stack, subject to the scope rules for identifiers. In Fortran, on the other hand, blocks (program units) and procedures (subprograms) are disjoint, storage allocation is static, and store availability and sharing is organised by the provision of COMMON storage. What organisation and facilities does PL/I have?
Brian Meek
2.5. Other Data Types
Abstract
In both Algol and Fortran variables taking truth values can be declared, and Boolean or LOGICAL forms a different data type from the arithmetic data types. In PL/I the attribute concept means that there is really just one arithmetic data type, though any object of that data type will have certain attributes of scale, base and precision. Even complex quantities are part of this, since REAL or COMPLEX is simply another arithmetic attribute. As for Boolean, there is no direct equivalent at all, the nearest being a bit string of length 1. Bit strings are dealt with in section 2.5.3, since it is more convenient to discuss them after character strings (section 2.5.2). First, however, we deal briefly with the COMPLEX attribute.
Brian Meek
2.6. Goto Facilities
Abstract
A simple statement label in PL/I is of the form that we have seen — an identifier. The usage is in fact like Algol 60, in that the label precedes the statement, and is separated from it by a colon. PL/I is like Algol 60 Modified (strictly, this should be the other way round) rather than Algol 60 Revised in that integer labels (statement numbers) are not allowed as alternatives. PL/I is also like Algol in that a statement may have more than one label, in principle as many as the programmer wishes. As in Algol, this facility is not much needed in practice.
Brian Meek
2.7. Other Facilities
Abstract
A good many of the features discussed in the corresponding chapter of part 1 have already come up in earlier chapters of part 2, such as own variables and EQUIVALENCE. In this chapter we tidy up some outstanding points, and briefly introduce some further features of PL/I. We start with the question of storage management. So far mention has been made of three kinds of storage attribute: AUTOMATIC, where the object goes into dynamic storage, STATIC, where it goes into static storage, and BASED, where it is superimposed over other items. It was also mentioned that there are four classes of storage, so one more remains to be described.
Brian Meek

Algol 68

Frontmatter
3.1. Basic Facilities
Abstract
This looks almost like an Algol 60 program. It has upper- and lower-case letters, typographically distinguished keywords identical to those in Algol 60, semicolons, the ‘colon equals’ assignment symbol, free format, variable declarations, long identifiers — everything one would expect from previous knowledge of Algol 60. The only slight oddity is the double bracketing in the input-output statements, but even that could be imagined in Algol 60 as a feature of some dialect. On this showing, Algol 68 looks as though it is going to be simply an extension of Algol 60.
Brian Meek
3.2. Choice Clauses
Abstract
In chapter 3.1 the concept of an ‘enclosed clause’ was introduced, and the simplest example, a closed clause, was discussed in more if not complete detail. In this chapter we introduce choice clauses, another form of enclosed clause, which are the nearest equivalent to conditional statements (and expressions) in the other languages. There are three kinds of choice clause, but only two will be discussed in this chapter, since the third is dependent on another concept which will not be met until later.
Brian Meek
3.3. Arrays and Iterations
Abstract
In Algol 68 arrays are called ‘multiple values’. The most straightforward way of creating a multiple value is to use a ‘row display’. An example of a row display is
which is a collateral clause all of whose components are of mode int. Collateral clauses have various uses, but when treated as a row display the mode of the above clause is ‘row of int’, otherwise written [ ] int. This, then, introduces ‘rowing’ as a means of developing further modes from the primitive modes. It should be noted that the term ‘rowing’ is applied both to the explicit process of creating a new mode by making a ‘row’, that is, array, of another mode, and to the coercion which in certain circumstances performs the equivalent mode conversion automatically. For the moment it is the explicit creation of rowed modes which we are considering; the coercion equivalent to it will appear later.
Brian Meek
3.4. Procedures and Program Structure
Abstract
It has already been noted in chapter 3.1 that the form of an Algol 68 program is a closed clause. Within this closed clause, we have seen, other closed clauses and other kinds of closed clause like choice and loop clauses can be nested. Thus an Algol 68 program has a nested ‘block’ structure just like an Algol 60 program. In the first part of this chapter this structure is related to questions such as the scope of identifiers (and other declared entities) and storage mechanisms.
Brian Meek
3.5. Other Data Types and Modes
Abstract
In this chapter the primitive modes bool and char are discussed, and the two means of producing new modes which have not so far been covered: structuring and uniting. Corresponding features to some of those discussed in the equivalent chapters in parts 1 and 2 have already been dealt with or touched on, such as plain modes derived from real and int by the use of long or short and pointer variables, but more will in fact be said about the use of long and short and ref at a later stage in this chapter.
Brian Meek
3.6. Goto Facilities
Abstract
Labels and goto statements are available in Algol 68, though the flexibility of the language and the range of choice and loop clauses make it even less likely than in PL/I that anyone familiar with the language would feel disposed to use them much. The presence of labels does, however, affect the discussion of serial clauses, so it is necessary for this reason, as well as for comparison with the other languages, to include some explanation of the facilities.
Brian Meek
3.7. Other Facilities
Abstract
Once again, many of the facilities that appear in the corresponding chapters of parts 1 and 2 have already been covered: conditional expressions, own variables, EQUIVALENCE, initialisations, generic functions, storage management, and so on. Indeed, so much of Algol 68 involves the generalisation and unification of concepts in the earlier languages that relatively little (within the pre-set limitations which excluded topics like input-output) remains to be discussed: in many respects Algol 68 is a very simple language. Of the features not so far mentioned which were dealt with in chapter 2.7, only ON conditions need to be mentioned (very briefly) in connection with Algol 68: there is no equivalent in Algol 68 to the ENTRY facility of PL/I and Fortran 77.
Brian Meek
Backmatter
Metadata
Title
Fortran, PL/I and the Algols
Author
Brian Meek
Copyright Year
1978
Publisher
Macmillan Education UK
Electronic ISBN
978-1-349-04052-0
Print ISBN
978-1-349-04054-4
DOI
https://doi.org/10.1007/978-1-349-04052-0