13 Aoû
2009
13 Aoû
'09
07:12
2009/8/13 lowly coder <lowlycoder@huoyanjinjing.com>:
Why does the following work?
(define foo 2) (pp (eval 'foo))
; --> 2
?
(sorry for my ignorane)
Because you are not in a macro. Here, you just have the runtime environment. In a macro, you mix the (current) macro environment, and the expansion environment. ;;; current macro env sample (define-macro (test-left) (define x 3) ;; currently known (pp x)) (define-macro (test-right) (pp x)) ;; error, x is not known (test-left) (test-right) ;;; expansion environment sample (define-macro (test-up) (eval '(define y "foo"))) (define-macro (test-down) (eval '(pp y))è ;; works (test-up) (test-down) P! -- Français, English, 日本語, 한국어