Announcements for Programming Languages

Check here periodically during the semester for announcements. If I need to clarify a homework problem, change a due date, give advice about using the course software, or broadcast some other similar information to the class, I'll put the announcement here.


Alternative classroom for April 25: On Wednesday, April 25, we will meet in Education 2103, a smart classroom, for student language presentations.

(The class will meet in the regular location, Robinson 103, on Monday, April 23; the language groups presenting on Monday have said that they do not need a smart classroom.)


Function "each" in Perl: Shaun asked in class on Wednesday (Apr. 4) about the behavior of the Perl function "each" after it reaches the end of the associative array. When it reaches the end, it returns an empty list, but then what?

This isn't documented as clearly as I'd like in Schwartz & Christiansen's Learning Perl, so I experimented. After "each" reaches the end and returns an empty list, it resets to the beginning, so that the next time "each" is called, it starts cycling through the associative array again. It doesn't matter whether "each" is called in a loop or not; it behaves the same regardless of whether it's called as an independent statement, in a loop body, or somewhere else.

This means, among other things, that you can have 2 while-each loops in a row, and they'll do the Right Thing: Both loops will process each item in the associative array, one at a time.


Revised due dates: I have updated the on-line schedule to reflect several new due dates.


Ada boolean types: Ada has a boolean type. Its name is Boolean, and its values are True and False. You may find it helpful on the homework to declare a boolean variable, something like this:

     Good_Coloring: Boolean;
and then at various points to say
     Good_Coloring := True;
or
     Good_Coloring := False;

Ada Homework: New due date

I had planned to describe the Ada compiler and give some data structures hints at the beginning of class on February 14. However, class was cancelled that day due to weather. Thus, I have decided to postpone the Ada homework due date; the Ada homework will be due Monday, February 26.

In the meantime, the Ada compiler and data structures information I was going to present in class is posted below.


Class cancellation: The university is closed today (Wednesday, February 14), due to the weather, so our class is cancelled today. We will have the Scheme test on Monday, February 19.


Compiling Ada programs:

The Ada compiler on elvis is called GNAT, and the command to use it is gnatmake.

Create your program using your favorite editor (vi, emacs, pico, etc.), and save it using the name of the main procedure, followed by an extension of adb; for example, if your program is called procedure check_coloring, then save your program as check_coloring.adb.

Compile the program using gnatmake, followed by the name of the program file, with or without the adb extension. For example,

     gnatmake check_coloring.adb
or
     gnatmake check_coloring

The compiler will produce an executable with the same name as the source file, but without the adb extension. To run the program, type that name at the elvis prompt. For example:

     ./check_coloring

Storing the graph coloring in Ada: In Ada, any discrete type can be used for array indexes; that is, you can use integers, characters, enumerated types, or booleans to index arrays.

The most natural data structure to use to store the graph coloring is an array indexed by characters, storing integers. The indexes correspond to vertices, and the integer stored at a particular index indicates the color of that vertex.

That is, if we have declarations:

	type VertexColorType is array('a'..'z') of Integer;
	VertexColor: VertexColorType;
then if VertexColor('a') = 1, this means vertex a has color 1; VertexColor('b') = 3 means that vertex b has color 3, and so on.

To make it easier to use this data structure, I will guarantee that all the vertices listed in the coloring will be consecutive lower case letters. Similarly, for the extra credit version of the problem, all the vertices in the graph will be consecutive lower case letters.


Ada character input:

To read the edges in the Ada program, use a sequence of input statements something like this:

        Get(Vertex1);    -- Read one endpoint
        Get(WhiteSpace); -- Read a space
        Get(Vertex2);    -- Read another endpoint
        Skip_Line;       -- Skip past the newline
Declare WhiteSpace (or a similarly-named variable) as a character variable.

The on-line quizzes are now ready. Please take the sample quiz and report any problems to me.


Help me find bugs! I am very interested in finding any remaining errors in the Scheme text. Accordingly, I will offer extra credit to anyone who finds an error in the Scheme text. This includes all kinds of errors: inaccuracies, typographical errors, grammatical errors, and unclear wording.


Answers to Frequently Asked Questions from previous semesters:

Question about used textbooks: I want to buy a used textbook, but the only used textbooks I can find are older editions. Is that okay?

Answer:

A 6th edition copy of Sebesta is okay.

A 5th edition copy of Sebesta is okay, but some of the section numberings have changed. If you use a copy of the 5th edition, check with me to get the correct reading assignments.

Use the current edition of the Scheme text. It's pretty cheap, and the newest version corrects some errors that appeared in older versions.

Any edition of Clocksin & Mellish is okay. As with Sebesta, however, if you use an earlier edition, check with me to get the correct reading assignments.


Question about using Scheme, Ada, and Prolog at home: I want to do my Scheme, Ada, and Prolog assignments at home, without having to dial in to campus. Are there interpreters and compilers I can use on my home computer?

Yes. Several free Scheme interpreters, including Scheme48, are available for Linux, Windows, and other platforms. If you prefer to work on your home computer, you can install one of these interpreters.

I will be using Scheme48 on elvis to grade your programs, so make sure to ftp your program to elvis and test it there before handing it in. Most interpreters adhere to the standards for the Scheme language, but sometimes you will find minor incompatibilities. By testing your program on elvis, you can make sure that your program is portable to the UNIX version of Scheme48.

Similarly, free Ada compilers and free versions of SWI-Prolog and YAP ("Yet Another Prolog") are available for a variety of platforms. As with Scheme, make sure to ftp your programs to elvis and test them with the interpreters/compilers there before handing them in.

If your program does not compile under elvis's compilers/interpreters, I will grade the program as "not compiling" (about 50 points off). It is your responsibility to test your programs on elvis before handing them in.


Nancy Tinkham
Computer Science Department, Rowan University

Valid HTML 4.0!