If a compiler neglects to make semantic checks, problems can occur
later. The Cool compiler has an undocumented option
that tells the compiler to muffle all semantic errors.
It is used as in
coolc -f bad.coolFor each of the following errors, try out the
-foption on programs that commit the error. Make sure you compile without
-fas well to make sure you don't have multiple errors in the file! Explain what results you get. For each check, classify the check as one of the following: (1) the check is actually unnecessary to ensure safety, or (2) removing the check may cause the code generator to crash, or (3) removing the check may cause the generated code to be malformed for SPIM so that execution cannot start, or (4) removing the check permits the generated code to do something illegal. For (1), you should try to convince me that the check is unnecessary. For (2), (3) or (4) a simple example demonstrating the problem suffices.
Mainclass must have no parameters.
Nulltype is not a subtype of
"hello" + "world"
overridemust override a method.
homework4.txt) in your homework4 directory of your AFS volume.
Inheritance and overriding can expose compiler bugs.
Write tests in
bad.cool (put in homework4/)
and use the test5 script as with previous assignments.
CS 754: Compiler Construction
C++ provides virtual and non-virtual multiple inheritance. Java only permits multiple inheritance of ``interfaces.'' Is Java's multiple inheritance like C++ virtual multiple inheritance or the nonvirtual kind? Explain! What are the pitfalls of full multiple inheritance? Explain using examples from a hypothetical extension of Cool with multiple inheritance.
Researchers have proposed ``traits'' and ``mixins'' as way to give expressive power while avoiding the problems of multiple inheritance.
Read and cite at least three research papers on such topics. Explain the main ideas and how they permit useful expressiveness while avoiding pitfalls of multiple inheritance.