Feedback Local variables are implicitly renamed 

Forum: Com Sci 221, U Chicago, Autumn 2001, Old Classwork
Re: News Assignment #6 due Monday, 12 November (Mike O'Donnell)
Re: Question Untitled (Kristina Matesa)
Date: 2001, Nov 11
From: Mike O'Donnell <odonnell@cs.uchicago.edu>

"Inside" and "outside" aren't standard terms. We distinguish variables local to a procedure from those global to a procedure. If a global variable is used inside a procedure it's just the same variable "inside" and "outside." If a global variable and a local variable have the same identifier, they are still different variables.

Under static scoping rules (which we are using independently of the parameter-passing strategy), if a global variable is passed as part of an actual parameter to a procedure containing a local variable with the same identifier, then the formal parameter refers to the global meaning, just as if the local variable had been renamed. For example,


var y

procedure P(x)

  var y

  x := x+1

  y := x+1

  x := y+1

end procedure

P(y)
is equivalent to

var y

procedure P(x)

  var z

  x := x+1

  z := x+1

  x := z+1

end procedure

P(y)




Mike O'D.


Messages

to: "Local variables are implicitly renamed"