CSC302 2007S, Class 16: Implementing LISP Admin: * Some delays due to storm. * A concern: Tomorrow's potential storm. Overview: * eval, continued. * Flaws in eval. * Graham's Claims. * Implementing Lisp. * Garbage Collection. /Our Problem/ * Assume a few basic operations have been implemented * Predicates: atom eq * List Operations: car cons cdr * Meta: quote - returns argument w/o evaluating it vs (lambda (x) x) - returns argument after evaluating it * Control: cond * This plus recursion gives us a whole language! * See eval Problem: Lisp, as defined, is dynamically scoped, rather than statically scoped. * When you refer to a variable, is its meaning determined by * Its context in the static program code * Its context in the dynamically running program code (define foo (lambda (x pred fun escape) (cond ((null? x) (escape)) ((pred? (car x)) (fun (car x))) ('t (foo (cdr x) pred fun escape))))) (let ((x 'hello)) (foo ... ... ... (lambda () x))) (let ((x 'error))