Assignment 4, due Feb. 13
Part of
the homework for 22C:112, Spring 2009
|
Always, on every assignment, please write your name legibly as it appears on your University ID and on the class list! All assignments will be due at the start of class on the day indicated (usually a Friday). The only exceptions to this rule will be by advance arrangement unless there is what insurance companies call "an act of God" - something outside your control. Homework must be turned in on paper and in class! Late work may be turned in to the teaching assistant's mailbox, but see the late work policy. Never push late work under someone's door!
a) Several files have been omitted from the above, most notably the object files. List the intermediate files that are omitted above that would be of interest to a C programmer. Do not list transient intermediate files that you hypothesize exist during compilation, only list the files you would expect to find in your directory as you develop this program. (0.5 points)
b) Give a well documented (but not overdocumented) makefile appropriate for this project. It should automatically make application when the user types the make command. (1.0 points)
For classes with large numbers of methods, Strachey's implementation leads to a large number of pointers to subroutines cluttering up the representation of each object.
A Question: An alternative is to have the method table of each class stored just once, with a pointer in each object in the class pointing to the method table for that class. In this case, each object would contain a field called myclass pointing to the method table for the class of that object. Write out, in C, the code that would correspond to this implementation of the method call object.method(p) (0.5 points)
A Question: How does this challenge the concept of an object hierarchy as used in languages such as Java, C++ and C# (not to mention Simula 67, where the idea originated). (0.5 points)
C programmers usually use a stream abstraction where the basic operations are fputc(), fgetc() and fseek() -- in terms of which the other routines in stdio.h can be written. Note that fputc() is implemented using read().
It is quite possible to substitute read(0,&ch,1) instead of ch=fgetc(stdin). Both get a single character from the standard input stream.
A Question: Obviously, using the C stream interface makes the code more portable, but there is also a performance reason to use the C interface instead of the system call. Explain this. (0.5 points)