From leavens@larch.cs.iastate.edu Tue Nov 14 21:17:53 2006 Date: Tue, 14 Nov 2006 21:17:52 -0600 (CST) From: Gary T. Leavens To: Adam M Weber Cc: Steve Shaner Subject: Re: hw9 question 8 Hi Adam, On Tue, 14 Nov 2006, Adam M Weber wrote: > I am confused on what you want to show for differences between the 1st > picture and the second picture can you clarify what you want from each spot? Recall that, in drawing such pictures, you draw them when execution reaches the named places, dynamically. That is, draw the first picture when execution of the call to f reaches the body of f, where the comment is. This will show, for example, the values of the formal parameters x, b0, and b1 for f (the value part of the call). Second, the second picture is for when execution finishes the call to f and returns from it. This will show the result of doing the result part of the call, copying the formal's final values back to the actual parameters that are variables. The formal parameters for f are no longer present. Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 From leavens@larch.cs.iastate.edu Wed Nov 15 18:16:48 2006 Date: Wed, 15 Nov 2006 18:16:48 -0600 (CST) From: Gary T. Leavens To: Adam M Weber Cc: Steve Shaner Subject: Re: Homework 9 q10 Hi Adam, On Wed, 15 Nov 2006, Adam M Weber wrote: > I was working on this problem and I was wondering if I was going about this > in the correct manner > > First step is to create a new location for formal parameters - do this by > creating a new vector or indirect arrays of formals correct? If you mean that you have to create a new list of targets, then yes. > -- so when we are mapping these values do we do this by mapping them into > direct or indirect targets? You will use direct targets, since they have their own storage. > Next assign current values into the new target locations. Yes, you copy the actual argument values to the new target locations. > Run the body Yes, be sure to save the result! > Somehow assign the formals back to the actuals and I'm assuming you do this > using setref of some form. Yes, you use setref! to do that. Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 ---------------------------------- From leavens@larch.cs.iastate.edu Wed Nov 15 21:08:27 2006 Date: Wed, 15 Nov 2006 21:08:27 -0600 (CST) From: Gary T. Leavens To: Kirk Sykora Cc: Steve Shaner Subject: Re: Typo on HW 9 Hi Kirk, On Wed, 15 Nov 2006, Kirk Sykora wrote: > I found a typo on HW 9 that caused me at least 30 minutes of debugging. For > Problem 4, the ref problem, after I passed all the hw test cases and > couldn't get the example in the problem to work I became weary of the > problem text. This is of course assuming that my reading of the problem and > understanding of references is correct :-|. > > The example you have reads: > > "For example, > > let x = 3 > in let rx = ref x > in let srv = setref(rx, 5) > in +(+(*(x,100), *(rx,10)), srv) > > would return 550." > > > I believe it should read: > > "For example, > > let x = 3 > in let rx = ref x > in let srv = setref(rx, 5) > in +(+(*(x,100), *(deref(rx),10)), srv) > > would return 550." > > The second to last line, where all the calculations are actually done, > should call deref on rx, because it is a reference. You are absolutely right. My apologies. I'll be correcting the homework in a minute... Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 From leavens@larch.cs.iastate.edu Thu Nov 16 15:42:29 2006 Date: Thu, 16 Nov 2006 15:42:28 -0600 (CST) From: Gary T. Leavens To: Com S 342 , Com S 342 TAs Subject: Validating due dates for homework 10 Hi all, I just wanted to certify that the due dates for homework 10 are unchanged, since I raised some doubt about them at the end of class today. Problems 1-3, which are due Tuesday, are mostly conceptual problems, that require you to only understand the concepts we discussed in class today (call by name and call by need), not the implementation details. So you should be able to do them by Tuesday. Have a nice break. Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 From leavens@larch.cs.iastate.edu Fri Nov 17 16:17:25 2006 Date: Fri, 17 Nov 2006 16:17:25 -0600 (CST) From: Gary T. Leavens To: Bancha Doungratanaex-chai Cc: Steve Shaner Subject: Re: HW9 Q10 (call by value-result) Hi Bancha, On Fri, 17 Nov 2006, Bancha Doungratanaex-chai wrote: > Do you mind take a look at my code below? How come it doesn't generate > the same result as the test case. I am pretty sure copy-value-result > function below are implemented wrong. But I believed that I already update > my ans to the old list. The problem seems to be that you aren't getting the results from the envrionment, which has the references that are changed as a result of assignment (set) statements. The targets aren't changed as a result of assigments, it's only the references that hold the targets that are changed. So what you are doing isn't going to get changes from assigments in the program. That is, when copying back, use apply-env on the environment to get the final values of the formal parameters. Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 --------------------------