Pascal Regina Bellamy Katitia Eaddy Corinthia Cunningham Anthony
Pascal Regina Bellamy Katitia Eaddy Corinthia Cunningham Anthony Mancuso
Problem Domain Designed to be efficient and concise First developed for instructional use Later extended for more wide-spread use
Historical Context Developed by Nicklaus Wirth after Algol -W passed up for Algol-68 Named after Blaise Pascal, a French mathematician Direct descendent from Algol-60 and Algol-W in 1971 Used from the late 60 s to the late 80 s for teaching programming, which it was originally designed for
Evolution of the Language Pascal was extended to better support the needs of programmers Pascal-P (Portable) was created to allow code to be ported to various operating systems (virtual machine!) Borland Apple created object-oriented extensions in the 1990 s Borland then created Delphi, which uses Pascal as its programming language ML and Modula are descended from Pascal
Language Concepts Case-insensitive Semicolon as a separator Functions and procedures Variable-length strings vs. arrays of characters Record (borrowed from COBOL) Repeat. . until (do. . while in C) In
Example 1 – A Sample Program Arith. Func; const Sentinel = 0. 0; var X : Real; begin writeln(‘Enter a real number, 0. 0 to stop’); writeln(‘X’, ‘Trunc(x)’ : 16, ‘Round(x)’ : 10, ‘Sqrt(Abs(X))’ : 15); readln(X); while X <> Sentinel do begin writeln(Trunc(X) : 17, Round(X) : 10, Abs(X) : 10: 2, Sqrt(X) : 10: 2); readln(X) end. Reference: http: //pascal-central. com/ppl/chapter 4. html
Example 2 – Using Procedures Program Something; procedure Do. Something. Else(x : real); begin writeln(‘Displaying half of your number: ’, x / 2) end; procedure Do. Something; var x : real; begin writeln(‘Enter a number. ’); readln(x); Do. Something. Else(x) end; begin Do. Something end.
Example 3 – While Version Program Factorial. While; var n, fact : integer; begin writeln(‘Enter n to compute n!. ’); readln(n); fact : = 1; while n > 1 do begin fact : = fact * n; n : = n – 1 end.
Example 3 – Repeat Version Program Factorial. Repeat; var n, fact : integer; begin writeln(‘Enter n to compute n!. ’); readln(n); if n > 0 then begin fact : = 1; repeat fact : = fact * n; n : = n – 1; until n = 0; end.
Example 3 – Downto Version Program Factorial. For; var n, i, fact : integer; begin writeln(‘Enter n to compute n!. ’); readln(n); fact : = 1; for i : = n downto 1 do fact : = fact * i end.
Comparison to Algol Designed to be simpler than its ancestor Algol-60 was the first block-structured language Foundation provided by Algol-W
Comparison to C Record vs. struct Variable-length string vs. char[] Begin. . end vs. { } Pascal is more strongly typed Pascal allows nested function definitions
- Slides: 13