csce 330 project algol 68 joe puziowael al-fayez gaurav shahronak patel
Post on 22-Dec-2015
214 Views
Preview:
TRANSCRIPT
History
ALGOrithmic Language Developed in Europe by an international group,
consisting of 7 different countries, in the late 1950’s
Very similar to FORTRAN Peter Naur and J.W. Backus worked on the
project. Was the debut of the BNF syntax. Designed specifically for programming scientific
computations
History (Continued)
Never became as commercially popular as FORTRAN or COBOL Was not compatible with IBM
Is considered the most important programming language in terms of influence on later language development
Many similar languages can (and are) referred to as “ALGOL-like” JAVA, C, C++, Pascal, Ada, FORTRAN, etc.
Design Goals
Design goals: general purpose, rigorously-defined
language Clears up trouble spots in ALGOL60
(but, Pascal more like A60 than A68 is)
orthogonality, extensibility
Features
Supports a Block Structure Two types of Parameter Passing
Value Name
Recursion Arrays Reserved Words
Failures and Shortcomings
The prime cause of the failure of ALGOL 68 was that too much was expected of it.
It was not widely implemented or not soon enough implemented.
Its formal definition was too complex to implement. ALGOL 68 is known to be ‘unreadable’. ALGOL 68 report was not properly typed hence too difficult
to read. ALGOL 68 semantic model was too big with lots of
extensions ALGOL 68 was a very mathematical language fairly difficult to understand, difficult to implement. The language was considered to complex for its time.
Key Ideas
User type declarations (modes) Reference mode (pointers of a sort) United modes (predecessor to variant
records) Auto declaration of FOR LOOP index User-specified operator overloading
Key Ideas (Continued)
Mode requirement for formals Casting: user-specified mode
conversion Redefinition of operator precedence Semaphores W-grammars - two-level grammar
Structure
ALGOL68 is block structured w/ static scope rules
ALGOL68's model of computation: static stack: block/procedure AR's; local data
objects heap: “heap” -- dynamic-- data objects
ALGOL68 is an expression-oriented language
Organization
Declarations: Must be given (FOR LOOP index only
exception) Can name new types (modes)
Imperatives (units) 15 major unit types Assignment is allowable side-effect of units
Algol 68 Modes
Primitive modes Compound Modes int --arrays Real --structures Char --procedures bool --sets string --pointers Compl(complex) bits bytes Sema (semaphore) Format (I/O) file
Other features of Algol 68
Storage management • Local storage on stack • Heap storage, explicit alloc and garbage
collection Parameter passing • Pass-by -value • Use pointer types to obtain Pass-by -
reference Assignable procedure variables • Follow “orthogonality ” principle rigorously
Source: Tanenbaum, Computing Surveys
Basic Syntax
Addition : “ + ” Subtraction : “ - ” Multiplication : “ * ” Division : “ / ” Exponentiation : “ ** ” Assignment : “ := ” Boolean Expressions
= , > , < , <= , >= , /=
Block Structure
First language to implement a block structure Similar in form to pascal
begin
…..
end;
Each block can have its own variables, visible only to that block (local variables). After the block is exited the values of all the local variables are lost.
Block Structure example
Example:
begin
own integer i; integer j,k;
i := j + k;
end; The integer i will have the value of j+k stored the
next time the block is entered
By using the “own” statement the variable will retain its value for the next time the block is entered
Parameter Passing
Two types of parameter passing: by Value, by Name Pass by Value works the same as in most other
languages Pass by Name is similar to pass by reference, but it adds
flexibility All parameters are pass by name unless otherwise
specified Example: can make a call “sum(i,2,5,x+6)” to the
procedure sumprocedure sum(i,j,k,l); value i,j,k;begin
i := i + j + k + lend;
(will execute as i := i + 2 + 5 + (x+6))
Recursion
Algol 68 Supports recursion
Example:
real procedure factorial (n);
begin
if n = 1 then
factorial := 1;
else
factorial := n* factorial(n-1);
end;
Arrays
Three types of arrays: real, integer, Boolean Each array must contain all the same types All arrays are of type real unless specified Can have multidimensional arrays Declarations:
array name1[1:100]; (1D array of type real) real array name2(-3:6,20:40); (2D array of type real) integer array name3, name4(1:46); (2 1D arrays of type integer) Boolean array name5(-10:n); (1D array of type Boolean)
(Allocated Dynamically)
Algol 68 presented the following innovations (among many):
A new level in language description with the semantics defined to mathematical precision as well as the syntax.
A formal method for describing, constructing and manipulating data types embodied in the language.
An abstract model of computation that can be applied across radically different (single and multi) processor designs (in direct contrast to C).
User-definable operators (in fact all the operators we normally take for granted as "built-in" are merely part of the Standard Prelude).
Support for parallel programming with the parallel-clause and Dijkstra semaphores.
Conclusion
General purpose algorithmic language with a clean consistent and unambiguous syntax.
Comprehensive fully-checked type-system covering structures, unions, pointers, arrays and procedures.
Procedures may be nested inside procedures and can deliver values of any type without you having to worry about where the storage is coming from.
User-defined operators including user-defined operator symbols.
Powerful control structures can deliver values of any type.
Conclusion
Dynamic sized arrays know their current bounds.
Array and structure displays can be used in any context.
Parallel programming with semaphores. Complex arithmetic. Declarations can be interleaved with
statements. Clear distinction between value semantics and
reference semantics. No distinction between compile-time constants
and run-time values.
References
http://portal.acm.org/citation.cfm?id=155365&coll=portal&dl=ACM&CFID=14638885&CFTOKEN=99793879
http://www.occl-cam.demon.co.uk/whitepaper.html#FirstExample:Animal
http://www.stanford.edu/class/cs242/slides/ml.pdf
top related