Lecture notes for classes 1--3 are available.
A BNF for Java from the official Java specification.
A BNF for the C programming language appears in Annex A (page 476 forward) of this publicly-available draft of the ANSI C spec.
Warning: the example BNF grammars for Java and C above do not use exactly the same conventions as our class.
Lecture notes: Basics of the C programming language (version 3) -- note, this version of the notes uses %p for printing a pointer, which is more correct than %x.
C for Java Programmers by Niranjan Nagarajan.
Lecture notes: Data types
Very long but important background reading: Java to C++ Transition Tutorial, maintained by the CS123 TA staff at Brown University. Start reading this in preparation for today's class, and keep reading it over the next few days.
A brief discussion of why Java strings are immutable.
Lecture notes: Abstract data types
Examples for separating code into header and implementation files: Location.cpp, Location.h, CityList.cpp, CityList.h, CityListMain.cpp, combined.cpp .
Lecture notes: Multiple inheritance and polymorphism
There are no lecture notes for today. Please take your own notes in class. You need to understand the basics of references and goto statements in C++, even though none of the programming assignments requires these. You also need to understand what operator overloading means, but you aren't required to learn the syntax. Please see the example code below for references, goto statements, and operator overloading:
In addition, you should be aware of the content of Dijkstra's 1968 discussion of go to statements and structured programming, Go To Statement Considered Harmful (available on Moodle). We will read and discuss this famous letter to the editor in class. Wikipedia has an excellent article on the goto statement. Interestingly, there is a separate Wikipedia page devoted to the phrase "considered harmful".
Files for working with scanning: cup.jar, example.cup, example.lex
Files for JFLex demo: LexTest.java, input-for-LexTest.txt, sym.java
calculator.zip for running JFlex and CUP on the calculator example.
Lecture notes will not be provided for most of this topic. We will stick reasonably closely to the textbook (Chapter 15, sections 0-5 and section 11 are the only ones we will cover).
Instructions for editing and running Scheme programs:
Please read textbook sections 15.5.12-14.
For more detailed examples, see the tail recursion handout.
Please take the CS majors' survey, if you haven't done so already.
Lecture notes on the implementation of Scheme.
Do you find Scheme's use of parentheses are little excessive? Check out the contents page of the book Introduction to Scheme, by Jerry Smith.
Fall pause -- no class.
Please take the class survey.
Most of the class will be a discussion of section 15.11 in the textbook. It may also be useful to browse a few of the hits on a web search for "functional versus imperative".
This class will also include some lab time to work on and ask questions about homework assignment 7.
If you have finished the homework, I recommend working on the optional exercises, taken from Dybvig's book, The Scheme Programming Language.
This class covers non-examinable topics: assignments in Scheme, object-oriented approaches in Scheme, vectors and hash tables in Scheme, and delegates and lambda expressions in C#. Some example Scheme code is available (note that this uses the Racket language, not the Advanced Student language we used for all our previous work).
This class will also include some lab time to work on and ask questions about homework assignment 7.
This class covers sections 5.1-5.4 and 6.12-6.14 of the textbook.
Contrast the textbook's definition of strongly typed with the discussion given in the first answer on the following page: http://stackoverflow.com/questions/430182/is-c-strongly-typed.
Exam 2.
This class covers sections 5.5-5.8 of the textbook, but sections 5.5.6 and 5.5.7 are excluded. (These sections cover dynamic scoping, which we will discuss in class, but which will not be included in any homework or exam questions.)
The brief code examples used in class are available as scope-examples.zip.
For running Prolog programs:
We will follow the textbook closely for this topic. Separate lecture notes will not be provided (mostly). However, the examples used in class today are available as course.pl.
The textbook uses unusual notation for some of the propositional logic operators (and, or, implies). We will use the standard notation as taught in the Dickinson discrete math course.
Some of the in-class examples are taken from http://en.wikibooks.org/wiki/Prolog
Lecture notes on prolog and first-order logic.
Some very brief notes on unification.
We do not study the use of arithmetic in Prolog (so you can skip the book section 16.6.6).
The file course-inference.pl contains the example used to explain the inference in Prolog.
Instructions for using tracing facilities with XGP:
teachingStudent(maccormick,gao).
The main topic for today is covered in section 16.7 of the textbook. Some brief additional notes on Prolog are provided. The accompanying file tree.pl demonstrates a non-trivial Prolog data structure.
Continue working on final project in class.
Earlier in the semester, I briefly discussed the recently-published paper from a bunch of MIT researchers: Towards Optimization-Safe Systems: Analyzing the Impact of Undefined Behavior, by Xi Wang, Nickolai Zeldovich, M. Frans Kaashoek, Armando Solar-Lezama. Some slides used by the first author when presenting the paper are also available. Note the puzzle on the last page of the slides -- it is highly relevant to this class! A file containing the relevant code from the puzzle is available: puzzle.c.