Dana Vrajitoru
C311 Programming Languages

Name, Scope, Binding

Name

Binding

Early / Late Binding

Dynamic Binding

Binding Time

Object Lifetime

Object Allocation

Function Space

Heap Management

Scope and Rules

Scope of a Binding

Static Scopes

Nested Declarations

(let ((A 1))
  (let ((A 2) (B A)) B)

Dynamic Scope

Dynamic Scope - Lisp

(defvar y 3)     ; y is a global

(defun f (x)
  (+ x y))   ; we think f uses the global y
(f 10) ; => 13

(defun g ()
  (let ((y 4) (a 1))
    (f a)))
(g) ; => 5   ; think again

Scope Implementation