Feedback please correct me 

Forum: U Chicago, Com Sci 221, autumn 2000
Re: News Take-home midterm exam, due 6 November (Mike O'Donnell)
Re: Question About the last problem in the Mid-term (Zhenglong Gu)
Date: 2000, Nov 08
From: Torkiat Krutpum torkiat

Let put things easier. If we do assignment like x = y. I know we should put r(y) in l(x), as we discussed
  in the class. But if we want to do *x = y. There are two possible ways to do this: put r(y) in the l(*x) or
  put l(y) in the l(x) Somebody help me out why the second is wrong:(

Well, I'm not sure if my understanding of the definition of r and l values is "precisely correct" though.  But I just want to try.  Maybe somebody could correct me.
I think it would make it easier if you think of x = y as SET r(x) equal to r(y).  This is because r(x), from what I think, is the record of x and l(x) is the label or the address of x.  So by saying put r(y) in l(x) makes sense because you put a record in a location.  So if you say put l(y) in l(x), it is the same as saying set the record of x to be the address of y.  (i.e. same as saying set r(x) equal to l(y) )
What *x = y means, according to my understanding, is that we set the r(*x) equal to r(y).  But *x means the object which has the address equal to r(x).  In other words, r(x) is a value that can be interpreted as an address .. i.e. as l(somebody).  So *x means that somebody.  And so r(*x) is the record of somebody.  Therefore, *x = y is the same as saying set r(somebdy) equal to r(y) for somebody is such that l(somebody) is equal to r(x).  Which is the same as saying PUT r(y) in l(somebody) for somebody is such that l(somebody) is equal to r(x).  Clearly this is NOT the same as saying PUT l(y) in l(x).   In other words, it is NOT the same as saying set r(x) equal to l(y).
 
Torkiat


Messages

to: "please correct me"