1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 14:00:21 +02:00

eval is actually compile

* module/ice-9/boot-9.scm (eval): Here at the tail of boot-9, replace
  the root definition of `eval' with a procedure that will call
  `compile'.

* test-suite/tests/syntax.test ("top-level define"):
  ("internal define"): Run unmemoization tests in the interpreter, using
  primitive-eval.
This commit is contained in:
Andy Wingo 2009-08-20 14:33:38 +02:00
parent 2fb924f64f
commit afe5e6baa7
2 changed files with 30 additions and 24 deletions

View file

@ -3492,6 +3492,14 @@ module '(ice-9 q) '(make-q q-length))}."
;;; Replace the C evaluator with the compiler.
;;;
(define (eval x env)
((@ (system base compile) compile) x #:from 'scheme #:to 'value #:env env))
;;; Place the user in the guile-user module.
;;;

View file

@ -1,6 +1,6 @@
;;;; syntax.test --- test suite for Guile's syntactic forms -*- scheme -*-
;;;;
;;;; Copyright (C) 2001,2003,2004, 2005, 2006 Free Software Foundation, Inc.
;;;; Copyright (C) 2001,2003,2004, 2005, 2006, 2009 Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
@ -807,21 +807,20 @@
(with-test-prefix "unmemoization"
(pass-if "definition unmemoized without prior execution"
(eval '(begin
(define (blub) (cons ('(1 . 2)) 2))
(equal?
(procedure-source blub)
'(lambda () (cons ('(1 . 2)) 2))))
(interaction-environment)))
(primitive-eval '(begin
(define (blub) (cons ('(1 . 2)) 2))
(equal?
(procedure-source blub)
'(lambda () (cons ('(1 . 2)) 2))))))
(pass-if "definition with documentation unmemoized without prior execution"
(eval '(begin
(define (blub) "Comment" (cons ('(1 . 2)) 2))
(equal?
(procedure-source blub)
'(lambda () "Comment" (cons ('(1 . 2)) 2))))
(interaction-environment))))
(primitive-eval '(begin
(define (blub) "Comment" (cons ('(1 . 2)) 2))
(equal?
(procedure-source blub)
'(lambda () "Comment" (cons ('(1 . 2)) 2)))))))
(with-test-prefix "missing or extra expressions"
(pass-if-exception "(define)"
@ -896,16 +895,15 @@
(interaction-environment)))
(pass-if "unmemoization"
(eval '(begin
(define (foo)
(define (bar)
'ok)
(bar))
(foo)
(matches?
(procedure-source foo)
(lambda () (letrec ((_ (lambda () (quote ok)))) (_)))))
(current-module))))
(primitive-eval '(begin
(define (foo)
(define (bar)
'ok)
(bar))
(foo)
(matches?
(procedure-source foo)
(lambda () (letrec ((_ (lambda () (quote ok)))) (_))))))))
(with-test-prefix "set!"