[   ^ to section index...   ]

CSE 341 : 3 May 2001

Page 1: Lexical scoping and nested functions; closures
Page 2: Closures and function applications ("activations").
Page 3: Higher-order functions and closures; "lambda = let"
Page 4: Scheme intro
Page 5: Scheme programs as data; a simple constraint solver using the eval function.
Page 6: Final thoughts on functional programming

Meta-note about the diagrams on pages 1-2: I have simplified the diagrams by drawing each "scope" (global, let-local, and function-local) as a single entity. In fact, global and let-local scopes are both more like a stack of mini-scopes, with each binding potentially shadowing previous bindings. When a closure is constructed, its environment pointer points only to already bound values. Later bindings that shadow these original bindings will not be visible to the closure, as in the following:

    - let
    =     val x = "hi";
    =     fun foo() = x ^ " there";
    =     val x = "yo";
    = in
    =     foo()
    = end;
    val it = "hi there" : string

However, drawing a new environment for every val binding would have made the diagrams much too complicated, so I limited myself to one environment per let or function application.


SML code examples, Scheme code examples

In-class slides: PowerPoint

Diagrams in better (non-rasterized) formats:


Keunwoo Lee
Last modified: Sun May 6 23:20:37 PDT 2001