1 / 20

David Evans cs.virginia/~evans

Lecture 4: All About Algol.

ember
Download Presentation

David Evans cs.virginia/~evans

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. Lecture 4: All About Algol “The Algol60 report was a fitting display for the language. Nicely organized, tantalizingly incomplete, slightly ambiguous, difficult to read, consistent in format, and brief, it was a perfect canvas for a language that possessed those same properties. Like the Bible it was meant, not merely to be read, but to be interpreted." Alan Perlis, The American Side of the Development of Algol, ACM SIGPLAN Noticies, August 1978. David Evans http://www.cs.virginia.edu/~evans CS655: Programming Languages University of Virginia Computer Science

  2. Menu • Algol Background • Evolution of Algol Procedures • Ambiguities in Algol60 [Knuth] • Finish milestones • Reminders: • Send email listing your paper choices • Work on your project proposals, bounce your initial ideas of classmates, me, John University of Virginia CS 655

  3. Algol Background • 1955: GAMM (European association of applied mathematics and mechanics) sets up committee to study development of a universal machine-independent programming language • May 1957: ACM forms committee to study universal programming language • Oct 1957: agree to joint effort • 1958: Preliminary Report – International Algebraic Language • Listed objectives: • As close as possible to standard mathematical notation, readable with little further explanation • Useable for describing computing processes in publications • Mechanically translatable into machine programs University of Virginia CS 655

  4. Algol 60 Committee • Committee consisting of 7 Europeans and 6 Americans (William Turanski died) • Europeans wanted a language to use • Americans using FORTRAN, other languages, etc. • “It is probably true to say that the collective knowledge of the total group of participants in the development of Algol 60 included all there was to be known about programming languages at the time.” [Naur 78] John Backus (FORTRAN), Alan Perlis (first Turing award), Peter Naur (ACM President), John McCarthy (LISP) University of Virginia CS 655

  5. Language Description before Algol Report • See back of manifest • Ad hoc syntax descriptions • Operational language descriptions • Machine/compiler specific University of Virginia CS 655

  6. Why three languages? “After two days of probing attitudes and suggestions, the meeting came to a complete deadlock with one European member pounding on the table and declaring: “No! I will never use a period for a decimal point”. Naturally the Americans considered the use of comma as decimal point to be beneath ridicule. That evening Wegstein visited the opposing camps and proposed defining the three levels of language.” Alan Perlis, The American Side of the Development of Algol, ACM SIGPLAN Noticies, August 1978. University of Virginia CS 655

  7. Procedures in FORTRAN I • Original “Programmer’s Reference Manual” [1956] – no way to define a function; could call pre-defined functions • Revised in 1957: • Define a function on a single line, with arguments • Call-by-reference: SUBROUTINE INCR(I) I = I + 1 RETURN END CALL INCR (2) N = 2 + 2 University of Virginia CS 655

  8. Algol 58 University of Virginia CS 655

  9. Zürich Report (1959) • Removed distinction between functions and procedures: allow procedures to return a value, blocks • Separate input and output parameter lists procedure F (Pi0, Pi1, ...) =: (Pp0, Pp1, ...) • Can list parameter as both input and output • Procedure call by text replacement, replace return to go to to statement after procedure • Didn’t support recursion (proprosal to add recursive delimiter rejected) University of Virginia CS 655

  10. Algol60 Procedures • Call-by-value or call-by-name determined by specifications • Removed need for distinction between input and output parameters • Defined by text replacement: • Value: additional block, local variables assigned to parameter • Name: replace throughout body enclosed parameter in parentheses “whenever syntactically possible” • Modified body inserted in place of call University of Virginia CS 655

  11. Jensen’s Device real procedure InnerProduct (z, y,n, j); value n; integer n; begin real a; a := 0; for j = 1 step 1 until n do a := a + z * y; InnerProduct := a end Sample calls: InnerProduct (A[i], B[i], 10, i) InnerProduct (M1[i,i], M2[k,i], 10, i) University of Virginia CS 655

  12. Call: InnerProduct (A[i], B[i], 10, i) begin real a; a := 0; for i = 1 step 1 until 10 do a := a + A[i] * B[i]; InnerProduct := a end Call: InnerProduct (M1[i,i], M2[k,i], 10, i) begin real a; a := 0; for i = 1 step 1 until 10 do a := a + M1[i,i] * M2[k, i]; IP := a end University of Virginia CS 655

  13. Ambiguity 1: Side Effects • If side effects are permitted, order of evaluation matters! begin integer a; integer procedure double(n) value n; integer n; double := n := n * 2; a := 2; outint (a * double(a) * double(a)); end. • Question: Have modern languages resolved this? University of Virginia CS 655

  14. Ambiguity 3: For Loops • Overly general and complicated • What were they (over) reacting to? • Semantics defined by formal translation (but they probably didn’t really mean it) for V := A step B until C do S  V := A; L1: if (V – C) * sign(B) > 0 then go todone; S; V := V + B; go toL1; University of Virginia CS 655

  15. Ambiguity 4: Specifications • 5.4.5: “Specifications (type declarations) of formal parameters called by value must be supplied and specifications of formal parameters called by name may be omitted.” (I don’t understand Knuth’s confusion.) • What are the advantages and disadvantages of not specifying call-by-name parameters? University of Virginia CS 655

  16. Ambiguity 7: own • Initialization: no way to initialize an own variable • Easy to fix with declaration syntax? (American Standards Subcommittee claims it is.) • Dynamic and Static Interpretation • Problem having to do with defining calls by expanding procedure bodies University of Virginia CS 655

  17. Static/Dynamic Own? begin procedure P begin owninteger n; if (n > 2) thenbegin P1; P2; end; end; L1: P3; P4; go toL1; end; University of Virginia CS 655

  18. Ambiguity 8: Numeric Labels <label> ::= <identifier> | <unsigned integer> begin integer val; val := 7 go to val; 7: val := 8; go to val; comment yikes! val: … end University of Virginia CS 655

  19. Correction 1: if/else definition “The construction else <unconditional statement> is equivalent to elseif true then <unconditional statement>” (4.5.3.2) LISP (before Algol 60): (cond (p1 e1) (p2 e2) ... (pn en)) Go from left to right, first pi that is true, value is ei; If no pi is true, value of expression is undefined University of Virginia CS 655

  20. Continue History Discussion • What are the important developments I left out? • Use Wenger paper and your experience/knowledge of things that have happened since 1976. • Organize them into milestones. • If time permits: • Develop a better overall history that includes all the important developments. University of Virginia CS 655

More Related