Assignment 3, Storage bindings and type equality
Due 9/17/03 12 noon
(To be done with your group)

As with all assignments, you must submit this assignment using the web interface.

You will need to refer to Mystery grammar to answer these questions.  For questions using the PL-Detective, keep in mind that the system may provide different semantics to different groups.  In other words, your group's answers may or may not be compatible with the answers by another group.

The most important part of this assignment is not the final answer (e.g., the type compatibility mechanism) but the reasoning that led to the answer.  Thus, don't leave the write up to the last minute!   Also since the number of attempts you can submit to the PL-Detective (e.g., number of PRINTs that you can execute) is limited, it is worth discussing each submission to the PL-Detective with your group.

Note that the PL-Detective link for each question is different.  Please use the appropriate link for each question.

  1. The textbook defines four kinds of storage bindings: static variables, stack-dynamic variables, explicit heap-dynamic variables, and implicit heap-dynamic variables.  Of these categories, we will consider only the first three kinds in this question (i.e., ignore "implicit heap-dynamic variables). 

    Mystery allows programs to declare variables associated with any block (delimited by BEGIN...END).    However, declaring variables is just a matter of syntax.  The kind of variables that Mystery actually supports (i.e., the semantics) is actually a mystery.  In this assignment you will put on your detective hat and try to figure out what kinds of variables Mystery supports.  To accomplish this you will submit programs to the PL-Detective, observe any outputs or errors, and make inferences.  Based on the output you receive, you may continue the interrogation by submitting another program or decide that you have solved the mystery.

    1. Based on an inspection of its syntax, do you believe that Mystery supports explicit heap-dynamic variables?  Explain and justify your answer.

    2. Determine and describe the storage bindings of the variables associated with blocks in Mystery.  Use this link to access the PL-Detective.  You can use upto a total of three executed PRINT commands in your interrogation (e.g., if you submit two programs, the total number of values the two programs print out combined should not exceed three).  Note that programs with syntax errors will not count towards your total since a program with a syntax error will not execute PRINT.  You will lose 5% of the points for this question for each additional PRINT that you execute.  The PL-Detective keeps track of all programs ever submitted by your group. (Hint: your answer to part (i) should help eliminate some possibilities for part (ii))

    3. Give the evidence and your reasoning based on which you arrived at your conclusions.  The evidence takes the form of programs you submitted and the output you received.  The reasoning takes the form of text that describes in detail what conclusions you drew from each program-output pair. 

  2. The textbook defines two kinds of type compatibility mechanisms: name type compatibility and structure type compatibility.  In this exercise, you will figure out the type compatibility mechanism used by mystery.  As with the previous exercise, you will accomplish this by submitting programs to the PL-Detective and observing the results.  Use this link to access the PL-Detective.  Keep in mind that different types in a given language may use different type compatibility mechanisms .  

    1. Determine and describe mystery's type compatibility mechanism by submitting programs to the PL-Detective.  For this part, ignore TYPE declarations (TYPE declarations are similar to typedef in C and C++.  For example, TYPE T = INTEGER in  mystery creates a new type name T for the type INTEGER.  This declaration is similar to typedef int T in C/C++).  Write this as if you are writing a language definition: i.e., your description should be precise and complete enough that a reader can take any two types in mystery (that do not use any type names declared using TYPE) and determine whether or not they are compatible.  You may submit up to 6 programs to the PL-Detective.  You will lose 5% of the points for this question for each additional program that you use.  Submitted programs that fail due to syntax errors (note: type errors are not syntax errors) do not count in your total.

    2. Present an argument for your answer to the previous part.  Your argument should include the evidence (programs you submitted to the PL-Detective and the output) along with a carefully reasoned argument explaining how your answer to (i) is justified by your evidence.

    3. Give one point in favor of and one point against mystery's type compatibility mechanism (which you just discovered).  Explain your point referring to the characteristics in Table 1.1 in text.

    For the purpose of this assignment you should assume that an assignment, lhs := rhs, is legal only if the type of lhs and rhs are compatible.  Assume that the type of a constant number (e.g., 5) is INTEGER.

  3. In this question you will determine how mystery's  TYPE declarations affect type compatibility.  In other words, after TYPE T = <some type> are T and <some type> compatible?   Use this link to submit programs to the PL-Detective.

    1. Determine and describe how mystery's  TYPE declarations affect type compatibility.  Write this as if you are writing a language definition: i.e., your answer to this question combined with your answer to question 2 should allow a reader to determine the compatibility of any two types in mystery's  including ones that use type names declared using TYPE.  You may submit upto 2 programs to the PL-Detective in your investigation.  Each additional program is charged 5% of the points for this question.  Submitted programs that fail due to syntax errors (note: type errors are not syntax errors) do not count in your total.

    2. Present an argument for your answer to the previous part.  Your argument should include the evidence (programs you submitted to the PL-Detective and the output) along with a carefully reasoned argument explaining how your answer to (i) is justified by your evidence.

    3. Give one point in favor of and one point against the semantics that you just discovered.  Explain your point referring to the characteristics in Table 1.1 in text.

  4. (Extra credit question) As we discussed in class, name type compatibility can create difficulties when writing distributed programs.  It seems a paradox that Java has name type compatibility yet it supports distributed programming (via, for example, RMI and Serialization).  Investigate and report on how this works in Java, giving appropriate references and quotes from Java documentation.  Note: this will require quite a lot of research (probably on the web) on your part so allocate your time accordingly!