1 / 12

ALGOL 60

ALGOL 60. Design by committee of computer scientists: Naur, Backus, Bauer, McCarthy, van Wijngaarden, Landin, etc. Influence later languages : PL/I, Pascal, Algol68, (C)

uzuri
Download Presentation

ALGOL 60

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ALGOL 60 • Design by committee of computer scientists: Naur, Backus, Bauer, McCarthy, van Wijngaarden, Landin, etc. • 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)

  2. ALGOL DESIGN GOALS • Close as possible to mathematical notation • Use for describing computing processes • publication language (fonts, spacing, subscripts, etc. • reference language (official, but informal, documentation of the language) • hardware representation (machine character sets, etc.) • 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 <variable> := for_list do • for_list ::= comma-separated list of elements • element ::= arithmetic expression • | A step B until C • | E while B

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

  6. WHAT'S IN A NAME? • A value? • A set of values? • A memory location? • A set of memory locations? • An essential decision that separate imperative from functional languages • 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 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) dynamic lexical * b a ** a a 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);} • 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 For example: to get4.5, first evaluate the denominator (g(a)) which yields2and has the side effect of settingato2 begin integer a; integer procedure f(x, y); value y, x; integer y, x; a := f := x + 1; integer procedure g(x); integer x; x := g := a + 2; a := 0; 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)

  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

More Related