CSC362.01, Class 2: An Abbreviated Introduction to Pascal Admin: * Surprize: No Quiz * Attendance is required * Almost everything I type on the screen gets recorded in an EBoard, available through the current outline or the EBoards link * How did you feel about lab 1? * Lack some fundamental skills, e.g., Unix terminal windows, Assembly, * You should mail me your results (day or so), but I do not grade them * Open-endedness * Read chapter 1 of ASU. Overview: * A short history of Pascal * Reflection: What are they key building blocks of an imperative language? * [To be filled in] Detour: Question four from lab 1 Good compiler design says * One intermediate language * Compile high-level language to intermediate * Compile intermediate to various targets pascal 68K \ / c - INT - i86 / \ fubula mips * In this class, I said "GNU trees" * On the eboard, I said "RTL" * About Pascal * Until the late 1950's, there were no high-level languages * First patch cords * Then "virtual patch cords" that employed the von Neumann principle * Then assembly * Four initial "threads" of programming langauge design * Fortran: Scientific Computation / Number crunching * COBOL: Business Computation / Information processing * LISP: AI computation / Simultating knowledge * Algol: Communicate algorithmic ideas * Nicklaus Wirth * Simplify * Keep key constructs * Never trust the programmer * Good for students * Support structured programming What aspects of an imperative language would you expect to learn? * Types (note that Wirth thought many errors were type based) * Control structures * Loops * Conditionals * Sequencing * Procedure/Function/Subroutine * Goto considered harmful * Key operators (+ , -, *, /, etc.) * Basic statements * Assignment * Input * Output * Overall program structure * Variables program NAME(LIST-OF-PORTS); CONSTANT-DECLARATIONS TYPE-DECLARATIONS VARIABLE-DECLARATIONS PROCEDURE-AND-FUNCTION-DECLARATIONS begin LIST-OF-STATEMENTS end. VARIABLE-DECLARATIONS var NAME1,NAME2,....NAMEn: TYPE; NM1,NM2,...NMm: TYPE; ASSIGNMENT STATEMENTS NAME := EXP; INPUT read(VAR); readln(VAR); OUTPUT write(EXP); writeln(EXP); In C, semicolons *terminate* statements, In Pascal, semicolons *separate* statements CONDITIONAL if TEST then STATEMENT if TEST then STATEMENT else STATEMENT if TEST1 then if TEST2 then STATEMENT1 else STATEMENT2 if (test1) if (test2) statement1; else statement2; if (itsFriday) { if (its115) { go to Sam's class } else { sleep } } if (itsFriday) { if (its115) { go to Sam's class; } } else { sleep; } Case Statement case (EXP) of VAL: STATEMENT; VAL: STATEMENT; ... VAL: STATEMENT end We need a "default" or "else" It's nicer to have more than one thing on the left VAL1,VAL2: STATEMENT Inclusive ranges are nice VAL1..VAL2: STATEMENT Combinations are nice 1..3, 5, 7..11: STATEMENT Compound statement begin STATEMENT; STATEMENT end Who cares about complete coverage?