Presentation is loading. Please wait.

Presentation is loading. Please wait.

ALGOL 60 Design by committee of computer scientists: Naur, Backus, Bauer, McCarthy, van Wijngaarden, Landin, etc. Design by committee of computer scientists:

Similar presentations


Presentation on theme: "ALGOL 60 Design by committee of computer scientists: Naur, Backus, Bauer, McCarthy, van Wijngaarden, Landin, etc. Design by committee of computer scientists:"— Presentation transcript:

1 ALGOL 60 Design by committee of computer scientists: Naur, Backus, Bauer, McCarthy, van Wijngaarden, Landin, etc. Design by committee of computer scientists: Naur, Backus, Bauer, McCarthy, van Wijngaarden, Landin, etc. Influence later languages : PL/I, Pascal, Algol68, (C) Influence later languages : PL/I, Pascal, Algol68, (C) Formal definition for syntax (rules for well- formed programs - BNF); English for semantics (assignment of meaning to program text) Formal definition for syntax (rules for well- formed programs - BNF); English for semantics (assignment of meaning to program text)

2 ALGOL DESIGN GOALS Close as possible to mathematical notation Close as possible to mathematical notation Use for describing computing processes Use for describing computing processes publication language (fonts, spacing, subscripts, etc. publication language (fonts, spacing, subscripts, etc. reference language (official, but informal, documentation of the language) reference language (official, but informal, documentation of the language) hardware representation (machine character sets, etc.) hardware representation (machine character sets, etc.) Mechanically translatable Mechanically translatable

3 ALGOL ISSUES Formal syntax Control structures Scope −lexical; (dynamic) Visibility −block structuring Lifetime −static (own); automatic Type checking −except for procedure parameters Parameter passing −call by name; call by value Attempt at precise semantics but ambiguities raised

4 CONTROL STRUCTURES if-then-else without endif (dangling else ) Compound statement / nesting Designational expressions and switches (yield labels) for loop / while −values specified by re-evaluated expressions − for := for_list do − for_list ::= comma-separated list of elements − element ::= arithmetic expression | A step B until C | E while B

5 BLOCKS AND COMPOUND STATEMENTS Compound statement: group of statements that can stand for a single statement syntactically Compound statement: group of statements that can stand for a single statement syntactically Block: a compound statement containing new declarations Block: a compound statement containing new declarations

6 WHAT'S IN A NAME? A value? A value? A set of values? A set of values? A memory location? A memory location? A set of memory locations? A set of memory locations? An essential decision that separate imperative from functional languages An essential decision that separate imperative from functional languages And places strict requirements on symbol table design And places strict requirements on symbol table design

7 EXAMPLE: LEXICAL VS. DYNAMIC SCOPING a: begin integer m; procedure P; m := 1; b: begin integer m; * P end ** P end dynamic lexical * b a ** a a Lexical scoping occurs when the binding of a variable reference to a declaration is made by searching upward in the set of nested blocks within the program source code (compile-time or static binding) Dynamic scoping occurs when the binding of a variable reference to a declaration is made by searching upward in the set of nested contexts in the program execution environ- ment (runtime binding) Algol uses lexical scoping

8 PARAMETER PASSING Actual argument - an expression that appears within a procedure call. The expression may be simply a variable name {f(x + 3);} Actual argument - an expression that appears within a procedure call. The expression may be simply a variable name {f(x + 3);} Formal (dummy) argument - an identifier used within a procedure definition as a surrogate for the actual argument {f(int a) integer a;... } Formal (dummy) argument - an identifier used within a procedure definition as a surrogate for the actual argument {f(int a) integer a;... }

9 A PROBLEM WITH CALL BY NAME procedure SWAP(x, y); real x, y; begin real t; t := x; x := y; y := t; end; i == 1; A[1] == 2; A[2] == 8; SWAP(i, A[i]) t := i; (t == 1) i := A[i]; (i == 2) A[i] := t; (A[2] == 1)

10 AMBIGUITY: SIDE EFFECTS begin integer a; integer a; integer procedure f(x, y); integer procedure f(x, y); value y, x; value y, x; integer y, x; integer y, x; a := f := x + 1; a := f := x + 1; integer procedure g(x); integer procedure g(x); integer x; integer x; x := g := a + 2; x := g := a + 2; a := 0; a := 0; outreal(1, a + f(a, g(a)) / g(a)) outreal(1, a + f(a, g(a)) / g(a))end Then, evaluate the numerator, first the a argument ( 2 ), then the g(a) nested call (yielding 4 and setting a to 4 ) For example: to get 4.5, first evaluate the denominator ( g(a) ) which yields 2 and has the side effect of setting a to 2

11 ALGOL PROBLEMS Premature implementation led to divisiveness Design by committee No I / O No types for procedure parameter parameters goto 's out of blocks for loop evaluation overly general Dynamic own array bounds Error handling not described Dangling else...

12 ALGOL CONCEPTS Formal syntax / precise semantics Scope / visibility / lifetime Lexical / dynamic scoping Type checking Block structure / compound Statement Control structures: −compound statement, procedure, conditional, switch −loop: list of elements, step, while Parameter passing mechanisms: −call by value, call by name


Download ppt "ALGOL 60 Design by committee of computer scientists: Naur, Backus, Bauer, McCarthy, van Wijngaarden, Landin, etc. Design by committee of computer scientists:"

Similar presentations


Ads by Google