set names of functions defined at the toplevel from `eval'
authorAndy Wingo <wingo@pobox.com>
Tue, 15 Nov 2011 22:38:40 +0000 (23:38 +0100)
committerAndy Wingo <wingo@pobox.com>
Tue, 15 Nov 2011 22:41:51 +0000 (23:41 +0100)
* module/ice-9/eval.scm (primitive-eval): Set the name of
  toplevel-defined functions.

module/ice-9/eval.scm
test-suite/tests/procprop.test

index 62e36ed..c0fa64c 100644 (file)
               (memoize-variable-access! exp #f))))
 
         (('define (name . x))
-         (define! name (eval x env)))
+         (let ((x (eval x env)))
+           (if (and (procedure? x) (not (procedure-property x 'name)))
+               (set-procedure-property! x 'name name))
+           (define! name x)))
       
         (('toplevel-set! (var-or-sym . x))
          (variable-set!
index 838f7a4..25dd4c2 100644 (file)
     (eq? 'display (procedure-name display)))
 
   (pass-if "gsubr"
-    (eq? 'hashq-ref (procedure-name hashq-ref))))
+    (eq? 'hashq-ref (procedure-name hashq-ref)))
+
+  (pass-if "from eval"
+    (eq? 'foobar (procedure-name
+                  (eval '(begin (define (foobar) #t) foobar)
+                        (current-module))))))
 
 \f
 (with-test-prefix "procedure-arity"