New version page

CU-Boulder CSCI 3155 - Homework Assignment 8

Upgrade to remove ads

This preview shows page 1 out of 3 pages.

View Full Document
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience

Upgrade to remove ads
Unformatted text preview:

CSCI 3155: Homework Assignment 8Due Thursday, November 19, 2009For this assignment, you will again work with a partner. You will write up and turn in thisassignment in pairs. Choose one of you to upload your write up to the moodle. Please name thefilehw8-YourIdentiKey-YourPartnersIdentiKey.pdfAlso, please include both of your PL-Detective user ids on your write-up and indicate which oneshould be considered the submission id. As always, you are welcome to discuss in larger groups.Just be sure to acknowledge those with which you discussed.BookkeepingExercise 1: Indicate in a sentence or two how much time you spent on this homework, howdifficult you found it subjectively, and what you found to be the hardest part. Any non-emptyanswer will receive full credit.If you would like share something about yourself that I do not already know, please do so. Andif your opinions have changed since the last submission, indicate one thing you like about the classso far and one thing you would change about it.ArraysExercise 2: Skill 15.1. Assume that Mystery uses the following rule for array subtyping:ARRAY I OF T <: ARRAY I OF U if T <: UGive a Mystery program that demonstrates that this subtyping rule is invalid. Note: you may notbe able to run your program in Mystery since in reality Mystery does not support this invalidrule.Exercise 3: Synthesis. Languages differ greatly in how they handle arrays. In this question, wewill focus on one issue with arrays: what happens when one array is assigned to another (assumingthe two arrays are of compatible types). Consider, for example, two variables declared as followsin Mystery syntax:VAR a : ARRAY [1 TO 5] OF INTEGER;VAR b : ARRAY [1 TO 5] OF INTEGER;BEGIN1. . .ENDWhat happens when we have an assignment a := b? If the assignment is “by reference” (whichis how Java works), variables of array type are represented as pointers and the outcome of theassignment is that a ends up pointing to the same array that b points to (i.e., a and b are aliasesfor the same array). If the assignment is “by value” (which is how Modula-3 works), then theassignment copies the contents of array b to array a.1. Use this link to figure out if Mystery uses array assignment by reference or by value. answer to this question should describe which one Mystery uses and also provide theevidence that enabled you to come to your conclusion. You submissions may execute up to atotal of 6 PRINT statements. Additional attempts will be charged at 5% of this question’spoints per executed PRINT.2. Discuss the relative advantages and disadvantages of array assignment by value and arrayassignment by reference.Parameter PassingExercise 4: In this question you, will discover the parameter passing mechanism for Mysteryusing this web page to access the PL-Detective. the purpose of this question assume that the actual’s type and the corresponding formal’s typemust be the same using structural type equality. Also assume that Mystery uses static scoping.1. Skill 16.1. For the following parameter passing implementations:• pass-by-value• pass-by-value-result• pass-by-reference• pass-by-namegive a realistic example for which the implementation is most suitable. You may want toconsult Section 9.5.2 of the text. Support your answer with clear arguments.2. Skill 16.2. Determine and describe the parameter passing mechanism in Mystery using theabove link. Be sure to state how Mystery’s implementation addresses the issues discussedin part (i). Your submissions may execute up to 10 PRINTs. Each additional PRINT willbe charged 5% of the points for the question.3. Provide and discuss the evidence that supports your case.2Exercise 5: Skill 16.2 Repeat parts (2) and (3) of the question above using this link (whichpotentially uses a different parameter passing implementation): 6: Skill 16.1. Assume that you have a procedure with a single formal parameter oftype T . Now, let’s suppose you want to call it with an actual parameter of type U . How shouldtypes T and U be related in order for the call to be safe with respect to types given each of thefollowing parameter passing implementations. Clearly explain your answer.1. Pass-by-value2. Pass-by-result3. Pass-by-value-result4. Pass-by-reference5. Pass-by-readonly-reference (i.e., same as pass-by-reference, but the argument cannot be mod-ified, only read).6.

View Full Document
Download Homework Assignment 8
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...

Join to view Homework Assignment 8 and access 3M+ class-specific study document.

We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Homework Assignment 8 2 2 and access 3M+ class-specific study document.


By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?