Notes from 10/25/02 - survey of issues about variable scope - (let ((v1 e1) ... (vn en)) body) - scope of all v1 .. vn is body only - this rules out recursive procedures - e1 is not in the scope of v1 - (letrec ... - alternate form - scope of v1 ... vn includes body AND all e1 ... en - allows recursion, and mutual recursion - these two do not change values of variables, but introduce new ones - note: outside variables w/ same name will be inaccesible within a let - (lambda (v1 ... vn) body) - scope is body - does it without establishing bindings - those are introduced later, upon application - note: the first let form is the same as ((lambda (v1 ... vn) body) e1 ... en) - letrec is possible to do, but much much harder as lambda - subtle point: scope in lambda is for that evaluation of the function; let is for all - (define v1 body) - scope of v1 is body, and whatever follows the define - if define is in an internal structure, the end of that structure is also the end of scope for the define - can have nasty rules when related to functions - earlier values matter for non-procedures, and don't matter for procedures - (define (f x1 ... xn) body) - scope of f is body and following - scope of variables is like lambda: body and not what follows - problem with lambda and substitution is called: "capture of a free variable"