Download presentation
Presentation is loading. Please wait.
1
ALGOL-60 GENERALITY AND HIERARCHY
Programming Languages Course Computer Engineering Department Sharif University of Technology
2
Outline History and Motivation Structural Organization Name Structures
Data Structures Control Structures
3
Outline History and Motivation Structural Organization Name Structures
Data Structures Control Structures
4
The International Algebraic Language
5
The International Algebraic Language
Designed by 8 representatives of ACM and GAMM Combined experiences of algebraic language design and implementing pseudo-codes. Essentially completed in 8 days Created a great stir Many dialects: NELIAC, JOVIAL Need for a single, universal, machine independent programming language. ACM and GAMM started disjoint studies. The official name: International Algebraic Language (IAL).
6
Objectives of Algol As close as possible to standard mathematical notation and readable with little further explanation. possible to be used for the description for computing processes in publications. Mechanically translatable into machine programs.
7
Algol-60 Final report was published in May 1960, revised in 1962.
The original algol-60 report is a paradigm of brevity and clarity, remains a standard. Syntax: BNF notation Semantics: clear, precise, unambiguous English- language description. BNF notation (Backus-Naur Form) :simple, concise, easy-to-read, precise method of describing syntax.
8
Outline History and Motivation Structural Organization Name Structures
Data Structures Control Structures
9
Hierarchical Structure
begin integer N; read int (N); begin real array Data[1:N]; integer i; sum := 0; for i := 1 step 1 until N do begin end … end end
10
Category of Construct Declaratives: bind name to the objects
Variables Procedures Switches Imperative: do the work of computation Control-flow Computational (:=)
11
The Familiar Control Structure
goto If-Then-Else For loop Procedure invocation
12
Compile-time, Run-time Distinction
FORTRAN: static compilation process Algol: not completely static Dynamic arrays Recursive procedures
13
The Stack, the Central Run-Time Data Structure
Dynamic allocation and deallocation are achieved by pushing and poping activation records on the stack.
14
Outline History and Motivation Structural Organization Name Structures
Data Structures Control Structures
15
Blocks and Compound Statements
A compound statement is a group of statements used where one statement is permitted. Blocks contain declarations, compound statements do not. An example of regularity in language design.
16
Example for i:=0 step 1 until N do for i:=0 step 1 until N do begin
if Data[i]>10 then Data[i]:=10; sum:=sum+Data[i]; Print Real(sum); end sum:=sum+Data[i]
17
The body of a for loop is one statement by default.
Example for i:=0 step 1 until N do for i:=0 step 1 until N do begin if Data[i]>10 then Data[i]:=10; sum:=sum+Data[i]; Print Real(sum); end sum:=sum+Data[i] The body of a for loop is one statement by default.
18
The compound statement is used where one statement is permitted.
Example for i:=0 step 1 until N do for i:=0 step 1 until N do begin if Data[i]>10 then Data[i]:=10; sum:=sum+Data[i]; Print Real(sum); end sum:=sum+Data[i] The compound statement is used where one statement is permitted.
19
Blocks Define Nested Scopes
In FORTRAN scopes are nested in two levels: global and subprogram-local. Algol-60 allows any number of scopes nested to any depth. Each block defines a scope that extends from the begin to the end. Name structures (such as blocks) restrict the visibility of names to particular parts of the program.
20
Example begin real x,y; procedure f(y,z); integer y,z; begin real array A[1:y]; end begin integer array Count [0:99]
21
Sample Contour Diagram
x y y f z A As the program grows larger, the context that the programmer must keep in mind becomes larger.->too many names are visible The goal of name structures is to limit the context with which the programmer must deal.->restricting the visibility of names to particular parts of the program. Variables declared in the outer block are visible in inner blocks. COMMON blocks in FORTRAN are redeclared in every subprogram that uses them -> Inconsistency possible->not in Algol count
22
Impossible Error Principle
Algol use of nested scopes prevents the programmer from committing errors that were possible in using FORTRAN COMMON blocks. Making errors impossible to commit is preferable to detecting them after their commission. Impossible Error Principle In comparison to FORTRAN COMMON blocks, Algol nested blocks eliminate errors. COMMON blocks were redeclared in every subprogram and there was possibility of inconsistency.
23
Static and Dynamic Scoping
24
Static and Dynamic Scoping
Static scoping: a procedure is called in the environment of its definition. Dynamic scoping: a procedure is called in the environment of its caller. Algol uses static scoping exclusively.
25
Example a: begin integer m; procedure P m:=1; b: begin integer m; P end; end
26
Example a: begin integer m; procedure P m:=1; b: begin integer m; P end With dynamic scoping, the value of this m is 1 when the program finishes block b.
27
Contour Diagram of Dynamic Scoping
(b) m Call P (P) DL m:=1
28
Example a: begin integer m; procedure P m:=1; b: begin integer m; P end; end With static scoping, the value of this m is 1 when the program finishes block b. With static scoping the assignment m:=1 always refer to the m declared in the first line.
29
Contour Diagram of Static Scoping
(b) m Call P (P) DL m:=1
30
Dynamic Scoping (Advantages)
begin real procedure sum; begin real S,x; S:=0; x:=0; for x:=x+0.01 while x<=1 do S:=S+f(x); sum:=S/100; end … To use the sum function it is necessary only to name the function to be summed f. begin real procedure f(x); value x; real x; f:=x 2 + 1; sumf:=sum; end
31
Dynamic Scoping (Advantages)
begin real procedure sum; begin real S,x; S:=0; x:=0; for x:=x+0.01 while x<=1 do S:=S+f(x); sum:=S/100; end … begin real procedure f(x); value x; real x; f:=x↑2 + 1; sumf:=sum; end
32
Dynamic Scoping (Advantages)
begin real procedure sum; begin real S,x; S:=0; x:=0; for x:=x+0.01 while x<=1 do S:=S+f(x); sum:=S/100; end … begin real procedure f(x); value x; real x; f:=x 2 + 1; sumf:=sum; end One advantage of dynamic scoping : A general procedure that makes use of variables and procedures supplied by the caller’s environment.
33
Dynamic Scoping (Problems)
begin real procedure discr(a,b,c) values a,b,c; real a,b,c; discr:=b↑2-4хaхc; procedure roots(a,b,c,r1,r2); value a,b,c; real a,b,c,r1,r2; …d:=discr(a,b,c); … end . roots(c1,c2,c3,root1,root2);
34
Dynamic Scoping (Problems)
begin real procedure discr(a,b,c); values a,b,c; real a,b,c; discr:=b↑2-4хaхc; procedure roots(a,b,c,r1,r2); value a,b,c; real a,b,c,r1,r2; …d:=discr(a,b,c); … end . roots(c1,c2,c3,root1,root2); begin real procedure discr(x,y,z); value x,y,z; real x,y,z; discr:=sqrt(x ↑2); . roots(acoe,bcoe,ccoe,rt1,rt2); end
35
Dynamic Scoping (Problems)
begin real procedure discr(a,b,c); values a,b,c; real a,b,c; discr:=b↑2-4хaхc; procedure roots(a,b,c,r1,r2); value a,b,c; real a,b,c,r1,r2; …d:=discr(a,b,c); … end . roots(c1,c2,c3,root1,root2); begin real procedure discr(x,y,z); value x,y,z; real x,y,z; discr:=sqrt(x ↑2); . roots(acoe,bcoe,ccoe,rt1,rt2); end The roots procedure will use the wrong discr function to compute its result.
36
Dynamic Scoping (Problems)
begin real procedure discr(a,b,c); values a,b,c; real a,b,c; discr:=b↑2-4хaхc; procedure roots(a,b,c,r1,r2); value a,b,c; real a,b,c,r1,r2; …d:=discr(a,b,c); … end . roots(c1,c2,c3,root1,root2); begin real procedure discr(x,y,z); value x,y,z; real x,y,z; discr:=sqrt(x ↑2); . roots(acoe,bcoe,ccoe,rt1,rt2); end This is called vulnerability. The root procedure is vulnerable to being called from an environment in which its auxiliary procedure is not accessible.
37
Static and Dynamic Scoping
In dynamic scoping, the meanings of statements are determined at run-time. In static scoping, the meanings of statements are fixed. Static scoping aids reliable programming. Dynamic scoping is against the Structure Principle. The Structure Principle: The dynamic behavior of a program should correspond in a simple way with its static structure.
38
Blocks and Efficient Storage Management
The value of a variable is retained In the scope of that variable. In a block or structure that returns to the scope of the variable. Variables of disjoint blocks can never coexist. Much more secure than FORTRAN EQUIVALENCE. Implemented by a stack. EQUIVALENCE: The program might store into one variable(or array or whatever) while the other one was still needed.
39
Responsible Design Principle
Do not ask users what they want, find out what they need. Algol designers found out the problem that led to EQUIVALENCE and designed something better.
40
Outline History and Motivation Structural Organization Name Structures
Data Structures Control Structures
41
Primitives The primitive data types are mathematical scalars: integer, real, Boolean. Only one level of precision: real. No double-precision types, they violate Portability: Doubles need word size and floating point representation of the computer to be implemented.
42
Primitives (cont.) Complex numbers were omitted because:
They are not primitive. The convenience and efficiency of adding them to the language is not worth the complexity of it. string data type: a second hand citizen of Algol-60. Can only be passed to procedures as arguments. Does not cause a loophole in the type system, as it does in FORTRAN. Algol was the last major language without strings. Complex variables, arrays, parameters, syntax for writing them, coercions between complex numbers and other values->
43
Zero-One-Infinity Principle
Algol follows the Zero-One-Infinity principle. Arrays are generalized in Algol: More than 3 dimensions. Lower bounds can be numbers other than 1. Zero-One-Infinity Principle The only reasonable numbers in a programming language design are zero, one, and infinity. In FORTRAN: identifiers: 6 chars, 19 continuation cards, arrays can have at most 3 dimensions. Lots of arbitrary numbers. Any limits should be none, one or infinite.
44
Dynamic Arrays Arrays are dynamic in a limited fashion:
The array’s dimension can be recomputed each time its block is entered. Once the array is allocated, its dimension remains fixed. Stack allocation permits dynamic arrays. The array is part of the activation record. The array’s size is known at block entry time.
45
Strong Typing Strong typing is where a language does not allow the programmer to treat blocks of memory defined as one type as another (casting). Example: Adding numbers to strings, doing a floating point multiply on Boolean values. This is different from legitimate conversions between types, i.e. converting reals to integers, which are machine independent operations. A strong type system prevents the programmer from performing meaningless operations on data. i.e. doing an integer addition on floating-point numbers. FORTRAN is not a strongly typed language.
46
System Programmers and the Type System
System programmers often have to violate the type system. A language’s type system is a safety feature. It must be circumvented when really necessary and by qualified programmers. Most system programming languages do provide some “loophole” through the type system. While programming a memory management system, it is necessary to treat memory cells as raw typeless storage. The I/O conversion routines must be able to manipulate the characteristic and mantissa of fps as ints.
47
Outline History and Motivation Structural Organization Name Structures
47 History and Motivation Structural Organization Name Structures Data Structures Control Structures
48
Primitive Computational Statement
The primitives from which control structures are build are those computational statements that do not affect the flow of control → ‘:=’ In Algol, function of control structures is to direct and manage the flow of control from one assignment statement to another Input-output
49
Control Structures, Generalization of FORTRAN’s
Algol: IF (logical expression) simple statement Branch instruction Fortran-> single, simple, unconditional stm Algol-> group of stms Else: an alternate, symetric if expression then statemtent1 else statement2
50
Control Structures, Generalization of FORTRAN’s
Algol for-loop Includes the functions of a simple Do-loop Has a variant similar to while-loop for NewGuess := improve(oldGuess) while abs( NewGuess - oldGuess)>0.1 do oldGuess := NewGuess for 1:=1 step 2 until M*N do inner[i] := outer [N*M-i]; for i:=i+1 while i < 100 do A [i] := i;
51
Control Structures, Generalization of FORTRAN’s
Algol for-loop Includes the functions of a simple Do-loop Has a variant similar to while-loop for NewGuess := improve(oldGuess) while abs( NewGuess - oldGuess)>0.1 do oldGuess := NewGuess for 1:=1 step 2 until M*N do inner[i] := outer [N*M-i]; while i < 100 do begin A [i] := i; i=i+1; end
52
Control Structures, Generalization of FORTRAN’s
Algol-60 control structures are more: Regular Symmetric Powerful General FORTRAN has many restrictions, because of: Efficiency ( the array restriction) Compiler simplicity (the IF restriction)
53
Control Structures, Generalization of FORTRAN’s
Restrictions are inexplicable for programmer. Irregularity in a language, makes it hard to learn and remember. the Algol designers’ attitude: “Anything that you thing you ought to be able to do, you will be able to do.”
54
Nested Statements FORTRAN IF:
if the consequent is more than 1 statement there are some problems: Problem of maintainability Irregular syntax, source of error FORTRAN DO-loop: begin and end of the loop is marked. irregu DO 20 I=1, N statement 1 statement 2 … statement m 20 CONTINUE
55
the Algol designers’ realized:
Nested Statements the Algol designers’ realized: All control structures should be allowed to govern an arbitrary number of statements. Algol-58-> bracketing->sample:endif Algol58 BNF description-> one bracketing construct All control structure even procedures govern Single stm
56
Nested Statements Compound statement: begin statement 1 statement 2
... statement n end
57
Nested Statements Begin-end brackets do double duty:
Group statements into compound statements. Delimit blocks, which define nested scopes.
58
Nested Statements Begin-end brackets do double duty:
Group statements into compound statements. Delimit blocks, which define nested scopes. Lack of orthogonality! Leads to problems! Block entry-> activation record Whethear or not to creat block entry-exit code New languages has separated Minor maintainance problem with for
59
Hierarchical Structure of Compound Statements
Hierarchical structure is one of most important principles of language and program design. Complex structures are built up by hierarchically combining single statements into larger compound statements.
60
Nested Led to Structured Programming
Many fewer GOTO-statements were needed in Algol-60. Programs were much easier to read. Edsger Dijkstra: “Go To Statement Considered Harmful.” IF: consequent more than on st else part Programming without goto! Communication of the ACM Goto must be abolished
61
Nested Led to Structured Programming
The Structure Principle the static structure of the program should correspond in a simply way to the dynamic structure of the corresponding computations. Difficulty of reading the programs with heavy use of GOTO is because of “conceptual gap” between static structure of program and its dynamic structure of corresponding computation Structured programming
62
Recursive Procedures Example: integer procedure fac (n);
value n; integer n; fac := if n =0 then 1 else n * fac(n-1);
63
Recursive Procedures There must be a memory location to hold the formal parameter! Only one location for n? Each invocation of fac has its own instance of the formal parameter n. Creating new activation record for fac each time it is called, is instantiation. Activataiton records Example of fac
64
Parameter Passing by Value
Example: procedure switch(n); value n, integer n; n:=3;
65
Parameter Passing by Value
Example: Procedure switch(n); Value n, integer n; n:=3; Useful only for input parameters!
66
Parameter Passing by Value
Pass by value is very inefficient for arrays: Real procedure avg (A , n); value A, n; real array A; integer n; begin . end; Duplicate space for entire array in AR. Waste time and storage
67
Parameter Passing by Name
Example: Pass by name is based on substitution! Procedure Inc (n); integer n; n := n+1;
68
Parameter Passing by Name
Implementation is not based on substitution! Copy Rule The procedure can be replaced by its body with the actuals substituted for the formals. Example I , A[k]
69
Parameter Passing by Name
Example: Pass by name is based on substitution! Procedure Inc (n); integer n; n := n+1; Satisfies Algol’s need for output parameters!
70
Parameter Passing by Name
Pass by Name Is Powerful! Example: real procedure Sum (k, l, u , ak); value l, u; integer k, l , u; real ak; begin real S; S := 0; for k:=1 step 1 until u do S := S + ak; Sum:=S; end;
71
Parameter Passing by Name
Pass by Name Is Powerful! Example: X := Sum (i, 1, n, v [i]) real procedure Sum (k, l, u , ak); value l, u; integer k, l , u; real ak; begin real S; S := 0; for I := 1 step 1 until n do S := S + v [i]; x := S; end; flexibility
72
Parameter Passing by Name
How is it implemented? Following the Copy Rule? Passing the address of the code sequence! A thunk is an invisible, parameterless, address-returning, function used by a compiler to implement name parameters and similar constructs. Pass text? Compile and exe each time
73
Parameter Passing by Name
Pass by Name is Dangerous and Expensive! Example: Swap (A[i], i) and Swap (i, A[i]) procedure swap (x, y); integer x, y; begin integer t; t := x; x := y; y := t ; end No way to define a swap in algol that works for all actual params In fortran its possible Pass by name abolished!
74
Parameter Passing Summarized
Pass by value: At call time, the formal is bound to the value of the actual. Pass by reference: At call time, the formal is bound to a reference to the actual. Pass by name: At call time, the formal is bound to a thunk for the actual. The reference does not change. Each time the thunk is evaluated returns different val..
75
Good Conceptual Models
Donald Norman (psychologist): “A good conceptual model allows us to predict the effects of our actions” 3 kind of conceptual models: Designer’s model System image User’s model; What is C M? A good model need not be correct. Designer’s model system construction-> implementation syntax System image created by designer-> manuals, diagrams,… primary medium User’s mode;
76
Expensive Out of Block GOTOs
Algol Scope Rule An identifier declaration is visible if we are nested within the block in which it occurs .
77
Expensive Out of Block GOTOs
Example: a : begin array X [1:100]; … b : begin array Y [1:100]; goto exit; end; exit : end A R
78
Expensive Out of Block GOTOs
Another example: begin procedure P (n); value n; integer n; if n=0 then goto out else P(n-1); P(25); out: end
79
Expensive Out of Block GOTOs
Another example: begin procedure P (n); value n; integer n; if n=0 then goto out else P(n-1); P(25); out: end The goto-statement must be implemented as a call of a run-time routine that find the appropriate activation record and deletes all the ones above it!
80
Future Interaction, a Difficult Design Problem
Algol visibility rules versus GOTO statement Problem of Interaction! Number of possiblr interactions Regular orthogonal--- simple
81
Future Interaction, a Difficult Design Problem
Designer must develop a “nose” for spotting possible problem areas!
82
Generality of the for-Loop
for var:=exp step exp' until exp" do stat for var:=exp while exp ' do stat for days:= 31, 28, 31, 30, do… for days:=31, if mod (year , 4) =0 then 29 else 28, 31, 30, do…
83
The Baroque for-Loop Example:
for i :=3, 7, 11 step 1 until 16, i/2 while i>=1, 2 step i until 32 Do print (i)
84
The Baroque for-Loop The Localized Cost Principle Users should pay only for what they use; avoid distributed costs. Binding time of loop params Any exp in the current for-list-element are reevaluated on each iteration About Baroque!
85
Handling Cases with the switch
Example: begin switch marital status = single, married, divorced; … goto marital status [i]; single: … handle single case goto done: married: … handle married case goto done: divorced: … handled divorced case done: end;
86
The Baroque switch Example: begin
switch S=L, if i>0 then M else N, Q; goto S [j]; end
87
The Baroque switch Example: begin
switch S=L, if i>0 then M else N, Q; goto S [j]; end goto if i>0 then M else N;
88
Handling Cases with the switch
Example: begin switch marital status = single, married, divorced; … goto marital status [i]; single: … handle single case goto done: married: … handle married case goto done: divorced: … handled divorced case done: end;
89
The Baroque switch Example: begin
switch S=L, if i>0 then M else N, Q; goto S [j]; end
90
The Baroque switch Example: begin
switch S=L, if i>0 then M else N, Q; goto S [j]; end goto if i>0 then M else N;
91
SYNTAX AND ELEGANCE: ALGOL-60
Programming Languages Course Computer Engineering Department Sharif University of Technology
92
Outline Syntactic Structures Descriptive tools: BNF Elegance
92 Syntactic Structures Descriptive tools: BNF Elegance Evaluation and Epilog
93
Outline Syntactic Structures Descriptive tools: BNF Elegance
93 Syntactic Structures Descriptive tools: BNF Elegance Evaluation and Epilog
94
Portability Principle
Software Portability Portability Principle Avoid features or facilities that are dependent on a particular computer or small class of computers. Machine independence. It affected syntactic structures
95
Free Format FORTRAN: fixed format Algol: free format
a format independent of details of the layout of the program. Natural languages Successors used free format.
96
Free Format “How a program should be formatted?” FORTRAN: fixed format
Algol: free format Programmers had to think about: “How a program should be formatted?” No particular format
97
Free Format Example: FORTRAN style for i:=1 step 1 until N do begin
real val; Read Real (val); Data [i] := val; end; sum:= sum + Data [i]; avg := sum/N;
98
Free Format Example: English style
for i:=1 step 1 until N do begin real val; Read Real (val); Data [i] := val; end; for i:=1 step 1 until N do sum:= sum + Data [i]; avg := sum/N;
99
Free Format Example: English style Remember the Structure Principle!
for i:=1 step 1 until N do begin real val; Read Real (val); Data [i] := val; end; for i:=1 step 1 until N do sum:= sum + Data [i]; avg := sum/N; Remember the Structure Principle!
100
Free Format Example: for i:=1 step 1 until N do begin real val;
Read Real (val); Data [i] := val; end; sum:= sum + Data [i]; avg := sum/N; Layout of program should obey structural principle
101
Levels of Representation
No universal character set! How to design the lexical structure? Using those symbols available in all char sets. Design independent of particular char sets. Unique specification of lexical structure , or .
102
Levels of Representation
Three levels of the language: Reference Language Publication language Hardware representations a [i+1] := (a [i] + pi ˣ r↑2 ) / ai+1 ← { ai + π ˣ r2 } / 6.02 ˣ1023 1-example in the algol report 2-for publishing algorithms in algol 3- algol implementors a (/i+1/) := (a (/i/) + pi * r**2 ) / 6,02e23
103
Problems of FORTRAN Lexics
Example: IF IF THEN THEN = 0; ELSE; ELSE ELSE = 0; Keywords of a language are invisible basic symbols
104
Problems of FORTRAN Lexics
Example: IF IF THEN THEN = 0; ELSE; ELSE ELSE = 0; Confusion! Keywords of a language are invisible basic symbols
105
Problems of FORTRAN Lexics
How does Algol solve the problem? if procedure then until := until +1 else do := false;
106
Lexical Conventions Reserved words: Keywords: Keywords in Context:
reserved words cant be used by the programmer Keywords: used word by the language are marked in some unambiguous way Keywords in Context: used words by the language are keywords in those context they are expected. Modern Algol Fortran pl1
107
Arbitrary Restrictions, Eliminated!
Number of chars in an identifier Subscript expression Remember the Zero-One-Infinity Principle! Reduces special cases
108
Dangling else What does the above code mean?
if B then if C then S else T; if B then begin if C then S else T end; if B then begin if C then S end else T;
109
Dangling else What does the above code mean? if B then if C then S else T; Algol solved the problem: “Consequent of an if-statement must be an unconditional statement”
110
Algol’s lexical and syntactic structures became so popular
that virtually all languages designed since have been “Algol-like”. Hierarchical structure and nesting
111
Outline Syntactic Structures Descriptive tools: BNF Elegance
111 Syntactic Structures Descriptive tools: BNF Elegance Evaluation and Epilog
112
Various Descriptive tools
Example: numeric denotations Giving Examples: Gives a clear idea, But not so precise. Integers such as: ‘-273’ Fractions such as: ‘ ’ Scientific notations: ‘ ’
113
Various Descriptive tools
Example: numeric denotations English Description: Precise, But not so clear! A digit is either 0,1,2,…,9. An unsigned integer is a sequence of one or more digits. An integer is either a positive sign followed by an unsigned integer or … . A decimal fraction is a decimal point immediately followed by an unsigned integer. An exponent part is a subten symbol immediately followed by an integer A decimal number has one of three forms: … . A unsigned number has one of three forms: … . Finally, a number … .
114
Various Descriptive tools
Backus-Naur Form (BNF)
115
Backus Formal Syntactic Notation
How to combine perceptual clarity and precision? Example: FORTRAN subscript expressions c v v + c or v - c c * v c * v + c′ or c * v - c′
116
Backus Formal Syntactic Notation
How to combine perceptual clarity and precision? Example: FORTRAN subscript expressions c v v + c or v - c c * v c * v + c′ or c * v - c′ The formulas make use of syntactic categories!
117
Naur’s Adaptation of the Backus Notation
BNF represents: Particular symbols by themselves, And classes of strings (syntactic categories) by phrases in angle brackets. <decimal fraction> ::== .<unsigned integer>
118
Describing Alternates in BNF
Example: alternative forms <integer> ::== +<unsigned integer> | -<unsigned integer> | <unsigned integer>
119
Describing Repetition in BNF
Example: recursive definition <unsigned integer> ::== <digit> | <unsigned integer><digit>
120
Extended BNF How to directly express the idea “sequence of …”?
Kleene cross Kleene star <unsigned integer> ::== <digit>+ <identifier> ::== <letter>{<letter>|<digit>}* <integer> ::== [+/-]<unsigned integer>
121
Extended BNF How to directly express the idea “sequence of …”?
Kleene cross Kleene star Why preferable? Remember the Structure principle!
122
Mathematical Theory of PLs
Chomsky type 0, or recursively enumerable languages Chomsky type 1, or context-sensitive languages Chomsky type 2, or context-free languages Chomsky type 3, or regular languages
123
Mathematical Theory of PLs
Languages described by BNF are context-free. →Mathematical analysis of the syntax and grammar of PLs.
124
Outline Syntactic Structures Descriptive tools: BNF Elegance
124 Syntactic Structures Descriptive tools: BNF Elegance Evaluation and Epilog
125
Design Has Three Dimensions
Scientific Efficiency Social Economy Symbolic Elegance
126
Efficiency Efficiency seeks to minimize resources used. Resources :
Memory usage Processing time Compile time Programmer typing time
127
Economy Economy seeks to maximize social benefit compared to its cost.
The public: The programming community. Trade offs are hard to make since values change unpredictably. Social factors are often more important than scientific ones. (E.g. major manufacturers, prestigious universities, influential organizations)
128
Elegance The feature interaction problem.
It is impossible to analyze all the possible feature interactions. All we need to do is to restrict our attention to designs in which feature interactions look good. Designs that look good will also be good. Good designers choose to work in a region of the design in which good designs look good. A sense of elegance is acquired through design experience. Design, criticize, revise, discard!
129
Outline Syntactic Structures Descriptive tools: BNF Elegance
129 Syntactic Structures Descriptive tools: BNF Elegance Evaluation and Epilog
130
Evaluation Algol-60 never achieved widespread use.
Algol had no input-output Little uniformity among input-output conventions. It was decided that input-output would be accomplished by using library procedures. Eventually several sets of input-output procedures were designed for Algol: It was too late!
131
Algol directly competed with FORTRAN
Same application area. FORTRAN had gained considerable ground. More focus on reductive aspects of Algol. IBM decided against supporting Algol. Algol became an almost exclusively academic language.
132
A Major Milestone Introduced programming language terminology.
Influenced most succeeding languages. An over general language: Quest for simplicity that resulted in Pascal. The basis of several extension, like Simula. Computer architects began to support Algol implementation.
133
Second Generation Programming Languages
Algol-60: The first second generation programming language. Data structures are close to first-generation structures. Hierarchically nested name structures. Structured control structures (e.g. recursive procedures, parameter passing modes). Shifted from free formats.
134
The End!
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.