Docsity

Practice Problem for Assignment 15 - Principle Programming Languages | COSC 4780, Assignments of Computer Science

Toggle sidebar
bg1
HW 15 Prof. Caldwell
Due: 2 April 2009 COSC 4780
Modify meaning of declaration to include variable declarations and update meaning of program
so that it uses the new function. use the semantic equations on page 65 to guide your new imple-
mentation โ€“ the rule for variable declarations is on page 53. I have added a procedure abstraction
as well.
As discussed in class and in the book; since variable declarations have a side effect (they modify
the store by extending it), this will entail modifying meaning of declaration to return a pair
env ร—store.
I have modified the type of declarations to include a new constructor Var of string and
locations have been extended to include a construct for referencing a location through a variable
name I of string. Environments have been extended to include a way of remembering locations
โ€“ so there are new functions:
apply intloc env : env -> string -> loc
update intloc env : string * loc -> env -> env
On page 65 โ€“ study how the modification of the return type for meaning of declaration
changes the equations for D1, D2and D1;D2โ€“ see how the stores are passed.
Note: The rule for Var declarations is on page 53 โ€“ the one on page 65 is stated in terms of
classes โ€“ which we have not implemented.
1

Partial preview of the text

Download Practice Problem for Assignment 15 - Principle Programming Languages | COSC 4780 and more Assignments Computer Science in PDF only on Docsity!

HW 15 Prof. Caldwell Due: 2 April 2009 COSC 4780

Modify meaning of declaration to include variable declarations and update meaning of program so that it uses the new function. use the semantic equations on page 65 to guide your new imple- mentation โ€“ the rule for variable declarations is on page 53. I have added a procedure abstraction as well. As discussed in class and in the book; since variable declarations have a side effect (they modify the store by extending it), this will entail modifying meaning of declaration to return a pair env ร— store. I have modified the type of declarations to include a new constructor Var of string and locations have been extended to include a construct for referencing a location through a variable name I of string. Environments have been extended to include a way of remembering locations

  • so there are new functions:

apply intloc env : env -> string -> loc update intloc env : string * loc -> env -> env

On page 65 โ€“ study how the modification of the return type for meaning of declaration changes the equations for D 1 , D 2 and D 1 ; D 2 โ€“ see how the stores are passed. Note: The rule for Var declarations is on page 53 โ€“ the one on page 65 is stated in terms of classes โ€“ which we have not implemented.