CS 1621 Fall 2005 Handouts

 

ifelse.cpp ifelse.adb – Dangling else problem in C++ and how it is handled in Ada.  Note that this issue decreases both readability and reliability of the language.

 

assign.cpp assign.java – Logic error in C++ via the = operator when == was intented.  Java prevents this logic error by converting it into a syntax error (if conditions must be boolean)

 

ex1.cl – Two different functions to reverse a list in LISP.  Read the comments for some interesting discussion of the two and their differences.

 

ex1.pl – Simple Prolog code to demonstrate the propositional nature of the language

 

lifetimes.cpp – Showing some variable lifetimes in C++

 

union.cpp variant.adb – How C++ unions are not type safe and how Ada variants are more so

 

types.adb types.cpp – Demo of some type compatibility in Ada and C++

 

pstrings.p astrings.adb cstrings.cpp Strings.java – Some issues with string types in various languages

 

resize.html – Discussion of run-time for resizing arrays

 

ptrarrays.cpp – Array access using pointers in C++

 

plusplus.cpp plusplus.java plusplus.pl – Evaluation of unusual expression in C++, Java and Perl.  In C++ the outcome is not defined by the language; however, it is not an error either.

 

Overflow.cpp – demo of importance of order of evaluation in seemingly commutative operations

 

loops.cpp – Demo of conditional loops in C++ -- simulating a pretest loop with a posttest loop and vice versa

 

fortest.p – For loops in Pascal

 

for.cpp – For loops in C++

 

params.adb params.cpp – Parameter passing in Ada and C++

 

cascade.st prompt.st – Simple Smalltalk example

 

person.cls student.cls personTest.st people.dat studentTest.st – Inheritance and polymorphism in Smalltalk

 

twodarry.cls twodTest.st – Another subclassing example in Smalltalk

 

poly.cpp – Simple polymorphism in C++

 

poly.java People.java Student.java Worker.java GenericComparator.java – Polymorphism in Java, plus a simple demo of reflection.

 

deadlock.java corrupt.java – Example showing how deadlock and data corruption can occur with multiple threads

 

recurse.pl – Demo of some recursive predicates in Prolog

 

lists.pl – Manipulating lists in Prolog

 

iocut.pl – I/O and "the cut" in Prolog

 

assert.pl – Asserting into the Prolog database