Lecture 9 Notes

2 ibid richie 967 642 0 588531 1

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: noted values are references to locations that contain expressed values. References are no longer expressed values. They exist only as the bindings of variables. ¡ ¡ Int Bool Proc Ref (ExpVal) Locations are created with each binding operation: at each procedure call, .  ¨¥ ¤ ExpVal DenVal , or ¥ ¨¥ ¤ ©  ! When an identifier appears in an expression, we first look up the identifier in the environment to find the location to which it is bound, and then we look up in the store to find the value at that location. Hence we have a “two-level” system for . ¥ ¨ Identifier Expression   ¡©  3 © 8£ ¥6¥ !¨¨ ¥ ¨ ¡ ¥ ©& 6 ! Expression :: expression. We use the syntax &! § ¥ 8£ Locations are changed by a Here the Identifier is not part of an expression, so it does not get dereferenced. In this design, we say that variables are mutable, meaning changeable. This design for doing this is called call-by-value, or implicit references. Most programming languages, including Scheme, use some variation on this design. 19 20 " ¡" ( § H ¡" ( IT£  " §§6  £ ¥ £  ¢  P" Q¡X6 H £  ¢  I6 ¥  ¢  ¨¨  § £ ¥ C £ ( ¥  ¡¦)   X!7%¡ §  ¢ 4£ ©8  © ¥ £  ¢  ¨¥ ¤ ¥ 5¨¥ ¤   ( ¥ £ ¥ S' ¢ ¦¨E" 5£ ¨¨ £  %¦0£  RRR6  § PW ¥ C (¥)  £ ¥ RRR ST£ ¦¥ § ¥ ¥ P H § Q¡" G£ I6 5£ ¨¨ ¥ C £  ¡¦B¨ ¤ ¥ (¥) ¥ © T£ ¦% ¥3 @ ©¥9  £ § ¢ 0  ¥ "  §  ¡#!7%¡ ¨ ¢  £ ¥ S75 ¢ § RRR  PQ¡" HG£ §I6 ¥5£ ¨¥¨  C£ ( ¥ ) ¥  ¡¦B¨ ¤ ¥ " A£ ¦% ¥3  £ § @¢ 0 ©¥9 ¥  " ¡#!¡ §£ ¥¦¥  ¥ ©¨¥ £   ¨¥ ¤  ¤ ¥ © ¦£ Let’s look at our two sample programs in this design: 5.3.1 Specification ¥ ¨¨ We can write the rules for dereference and easily. The environment now always binds variables to locations, so when a variable appears as an express...
View Full Document

Ask a homework question - tutors are online