Lecture 9 Notes

6 so instead of saying v 0 v1 1 exp

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: n with each other. In Scheme, this technique is used by the procedure to create unique symbols.  £ ( ¥ P" Q7¡X6 H  £ ¥ © X¥ £  ¢  G¥ §  ©¥  ©¥ £  ¢  §¨¥ ¥ §I6 H ¥  ¢  §¨©¨¨ © © £ ¥ ¥ £ ¥¦ £ ©  §¨¥ ©¨¦£ ¥ ©¥ £ §¥  ¥  8 © C ¡4 () ¢ ¤   X!¡ §  ¢ " ¡" 6  ¡ Exercise: What would have happened had the program been instead ( § H ¡" " ¥  ¨¥ ( 5¤ £ ( IT  §§6 5.2.2 Store-Passing Specifications In our language, any expression may have an effect. To specify these effects, we need to describe how each evaluation can modify the store, and what store should be used for each evaluation. In our specifications, we use to range over stores. We write [l v] to mean a store just like , except that location l is mapped to v. When we refer to a particular value of , we sometimes call it the state of the store. ¡ We use store-passing specfications. In a store-passing specification, the store is passed as an explicit argument to and is returned as an explicit result from  ¢ ¥  ¤ ! 6 & ¦ ¥ F 2 ¢   ¤ ! 6 & So instead of saying v 0 v1 1 $ " !# ¡" !  exp )  ¨¦ ©§¥ £ ¤¢  ¥ ¨¦ £ ¤¢ we write exp ¡ (  This asserts that expression exp , evaluated in environment and with the store in state 0 , returns the value v1 and leaves the store in a possibly-different state 1 . by writing n " !#  8£ ¥ !  £ ¢  6 ¡"!  " n Thus we can specify an effect-free operation like 42¨1)( 53¤§0§ & ' ¨¦ ©§¥ £ %¢  showing that the store is unchanged by evaluation of this expression. 7  v1 ) v1 ) # # 1 "! £ ¤¢ £ %¢ ¥ ©¨©§¥ 4 ¨  ¦ 2 ¨¦ ©§¥ "! £ ¤¢ £ %¢  ¥ ©©¦§" ¥ 4 " ¨ ¨ 2 ¨¦ ©§¥ !  ¥ %¢ £ 4   2¨ ¨¦ ¥  " !# "! £¢ ¤¢ ¤ ¨¦ ©§¥  0 1...
View Full Document

This document was uploaded on 03/17/2014 for the course CSG 111 at Northeastern.

Ask a homework question - tutors are online