If a compiler neglects to make semantic checks, problems can occur
later. The Cool compiler has an undocumented option -f
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
-f option on
programs that commit the error.
Explain what results you get. For each check, argue that (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.
Main class must have no parameters.
String.
null type is not a subtype of Boolean.
"hello" + "world"
override must override a method.
homework4.txt)
in your homework4 directory of your AFS volume.
Inheritance and overriding can expose compiler bugs.
Write tests in good.cool and 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.