Lecture 5 Notes

Lecture 5 Notes

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: d position 1, and refers to The combination of lexical depth and position is called a lexical address. §£ ¨¢ § £ ¢ £ ¢ § ¨ § ¦¢ ¥£ ¨  ¢  £ £ ¥ ¥ 7 We can classify the variable uses in an expression by where they are bound: $# %© Local variables are those bound by the immediately enclosing binder ( , or ). Non-local variables are those bound somewhere else in the expression. Free or global variables are those that are not bound in the expression. ,  ) © £#¡$# ¤¢%© For example, in the last line of  § ¦  ©      © ¥¦ § ¨ ! %#  § $© ¥¥ ¦¢ § £ ¢!&% $#© § !§ § !§ § §§§ )!!"!) ¥ £    © and are local, , , , and (global). are non-local, and any other variables are free 8 The binding of a variable is the value associated with it. Bindings are created by , so you can look at the specification to see how the binding is created. Formal parameters are bound when the procedure is applied:  #¢ ¢¡!£¡# £¥ ¢¦¡ % )'%#!  21&$""0§ v 43 5CB %)'%#! ¨ $((&$" ©§ xv xe 4 53 6 A @!%)¨7 (9$8§ -variable is bound to the value of its right-hand side. 4443 C5B is bound using its right-hand side as well. 6 A £#¡$# ¤¢%© @!%)¨7 1C9CD8§ § § F% 1&I§ @!%)¨7 1CQPCD8§ PC%79Q$91D$PC""PCE§ UT)#%7S%'S%FG% @!%)¨7 (CQ9$R§ 6 43 5H4 G%#%F% &CCE§ 1C9CD8§ @!%)¨7 e2 p x e1 e2 9 p x e1 44 C53 @!%)¨7 1C9CD8§ $# © A variable declared by a 444 C53 G%F% &CE§ e2 43 5H4 v x e1 e2 e1 xv 6 6 A e is bound when the procedure is applied. 4 ¤ $£# A variable declared by a The extent of a binding is the time interval during which the binding is maintained. In our little language (as in Scheme), all bindings have semi-infinite extent, meaning that once a variable gets bound, that binding must be maintained indefinitely (at least potentially). This is because the binding might be hidden inside a closure that is returned. In languages wi...
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