20-CS-4003-001 Organization of Programming Languages Fall 2018
Miscellaneous Ideas

Lambda calculus, Type theory, Formal semantics, Program analysis

Prev     Next     All lectures        Code

What does lambda do?

 ;; does nothing (lambda () (+ 3 4)) ;; evaluates to 7 ((lambda () (+ 3 4))) ;; it is possible that z is never used (define f (lambda (x y z) (if (zero? y) (/ x z) (/ x y)))) ;; divide by 0 error even though z not used (define test1 (lambda () (f 10 20 (/ 10 0)))) ;; it is possible that z is never used (define g (lambda (x y z) (if (zero? y) (/ x (z)) (/ x y)))) ;; no divide by 0 error (define test2 (lambda () (g 10 20 (lambda () (/ 10 0))))) ;; divide by 0 error (define test3 (lambda () (g 10 0 (lambda () (/ 10 0))))) - An important property of lambda is that no part of the body of a lambda expression is evaluated until the lambda expression itself is evaluated. This allows all kinds of computational possibilities. Shown here is an example of how the evaluation of arguments can be delayed until they must be used in the body.