~ chicken-core (chicken-5) e1dd32923238660c2d00b8ca011c5c0ee22dfd79


commit e1dd32923238660c2d00b8ca011c5c0ee22dfd79
Author:     Evan Hanson <evhan@foldling.org>
AuthorDate: Sat Apr 25 15:27:56 2015 +1200
Commit:     Evan Hanson <evhan@foldling.org>
CommitDate: Sat Apr 25 15:27:56 2015 +1200

    Convert the eval unit into a module
    
    Updates the "chicken", "r4rs", "r5rs" and "scheme" modules to reexport
    procedures from the eval module. These can be removed from the "chicken"
    module as other code is updated to use "chicken.eval" instead.
    
    Uses the fully-namespaced version of `eval` in generated import
    libraries.
    
    Moves `file-requirements` registration out of the eval unit's
    `##sys#do-the-right-thing` procedure and into an optional callback, in
    order to avoid a circular dependency on chicken.compiler.core.
    
    Removes declaration processing from the eval unit's
    `##sys#compile-to-closure`.
    
    Uses namespaced versions of some eval unit procedures, such as
    `repository-path`, in a handful of places, to simplify bootstrapping now
    that importing the latter requires the eval module to have been built.
    
    Modifies `eval-when` to treat its situation specifiers as raw symbols,
    so that the following evaluates to 1 rather than raising an error:
    
        (let ((eval #f))
          (eval-when (eval) 1)) ; => 1
    
    This version should be bootstrapped with itself before building from any
    subsequent commits.

diff --git a/batch-driver.scm b/batch-driver.scm
index 82c9b6b8..a4ab276b 100644
--- a/batch-driver.scm
+++ b/batch-driver.scm
@@ -29,7 +29,7 @@
 ;; Same goes for "backend" and "platform".
 (declare
   (unit batch-driver)
-  (uses extras data-structures files
+  (uses eval extras data-structures files
 	support compiler-syntax compiler optimizer
 	;; TODO: Backend should be configurable
 	scrutinizer lfa2 c-platform c-backend) )
@@ -178,12 +178,13 @@
 	      arg) ) ) )
   (initialize-compiler)
   (set! explicit-use-flag (memq 'explicit-use options))
-  (let ((initforms `((##core#declare
+  (let ((initforms `((import scheme chicken)
+		     (##core#declare
 		      ,@(append 
 			 default-declarations
 			 (if explicit-use-flag
 			     '()
-			     `((uses ,@units-used-by-default)) ) ) ) ) )
+			     `((uses ,@units-used-by-default)))))))
         (verbose (memq 'verbose options))
 	(outfile (cond ((memq 'output-file options) 
 			=> (lambda (node)
diff --git a/chicken-syntax.scm b/chicken-syntax.scm
index 73aa84ad..eaba3ab2 100644
--- a/chicken-syntax.scm
+++ b/chicken-syntax.scm
@@ -247,32 +247,29 @@
 (##sys#extend-macro-environment
  'eval-when '()
  (##sys#er-transformer
-  (lambda (form r c)
+  (lambda (form r compare)
     (##sys#check-syntax 'eval-when form '#(_ 2))
     (let* ((situations (cadr form))
 	   (body `(##core#begin ,@(cddr form)))
-	   (%eval (r 'eval))
-	   (%compile (r 'compile))
-	   (%load (r 'load))
 	   (e #f)
-	   (co #f)
+	   (c #f)
 	   (l #f))
-      (let loop ([ss situations])
+      (let loop ((ss situations))
 	(if (pair? ss)
 	    (let ((s (car ss)))
-	      (cond ((c s %eval) (set! e #t))
-		    ((c s %load) (set! l #t))
-		    ((c s %compile) (set! co #t))
-		    (else (##sys#error "invalid situation specifier" (car ss)) ))
-	      (loop (##sys#slot ss 1)) ) ) )
+	      (cond ((compare s 'eval) (set! e #t))
+		    ((compare s 'load) (set! l #t))
+		    ((compare s 'compile) (set! c #t))
+		    (else (##sys#error "invalid situation specifier" (car ss))))
+	      (loop (cdr ss)))))
       (if (memq '#:compiling ##sys#features)
-	  (cond [(and co l) `(##core#compiletimetoo ,body)]
-		[co `(##core#compiletimeonly ,body)]
-		[l body]
-		[else '(##core#undefined)] )
+	  (cond ((and c l) `(##core#compiletimetoo ,body))
+		(c `(##core#compiletimeonly ,body))
+		(l body)
+		(else '(##core#undefined)))
 	  (if e 
 	      body
-	      '(##core#undefined) ) ) ) ) ) )
+	      '(##core#undefined)))))))
 
 (##sys#extend-macro-environment
  'parameterize '()
diff --git a/chicken.import.scm b/chicken.import.scm
index 09f7e20e..7ecd469e 100644
--- a/chicken.import.scm
+++ b/chicken.import.scm
@@ -45,7 +45,7 @@
    call/cc
    case-sensitive
    char-name
-   chicken-home
+   (chicken-home . chicken.eval#chicken-home)
    chicken-version
    command-line-arguments
    condition-predicate
@@ -65,21 +65,23 @@
    current-milliseconds
    current-read-table
    current-seconds
-   define-reader-ctor
+   (define-reader-ctor . chicken.eval#define-reader-ctor)
    delete-file
    directory-exists?
+   (dynamic-load-libraries . chicken.eval#dynamic-load-libraries)
    enable-warnings
    equal=?
    er-macro-transformer
    errno
    error
+   (eval-handler . chicken.eval#eval-handler)
    exact-integer?
    exact-integer-sqrt
    exact-integer-nth-root
    exit
    exit-handler
    expand
-   extension-information
+   (extension-information . chicken.eval#extension-information)
    feature?
    features
    file-exists?
@@ -173,9 +175,10 @@
    keyword->string
    keyword-style
    keyword?
-   load-library
-   load-relative
-   load-verbose
+   (load-library . chicken.eval#load-library)
+   (load-noisily . chicken.eval#load-noisily)
+   (load-relative . chicken.eval#load-relative)
+   (load-verbose . chicken.eval#load-verbose)
    machine-byte-order
    machine-type
    make-blob
@@ -213,10 +216,10 @@
    register-feature!
    remprop!
    rename-file
-   repl
-   repl-prompt
-   repository-path
-   require
+   (repl . chicken.eval#repl)
+   (repl-prompt . chicken.eval#repl-prompt)
+   (repository-path . chicken.eval#repository-path)
+   (require . chicken.eval#require)
    reset
    reset-handler
    return-to-host
@@ -249,9 +252,7 @@
    vector-copy!
    void
    warning
-   eval-handler
    er-macro-transformer
    ir-macro-transformer
-   dynamic-load-libraries
    with-exception-handler)
  ##sys#chicken-macro-environment)       ;XXX incorrect - won't work in compiled executable that does expansion
diff --git a/core.scm b/core.scm
index b4b247ac..92e150c9 100644
--- a/core.scm
+++ b/core.scm
@@ -264,8 +264,7 @@
 
 (declare
  (unit compiler)
- (uses extras data-structures
-       scrutinizer support) )
+ (uses eval extras data-structures scrutinizer support))
 
 (module chicken.compiler.core
     (analyze-expression canonicalize-expression compute-database-statistics
@@ -318,6 +317,7 @@
 	chicken.compiler.scrutinizer
 	chicken.compiler.support
 	chicken.data-structures
+	chicken.eval
 	chicken.extras
 	chicken.foreign)
 
@@ -671,7 +671,18 @@
 				  '(##core#undefined)
 				  (let ((id (car ids)))
 				    (let-values (((exp f realid)
-						  (##sys#do-the-right-thing id #t imp?)))
+						  (##sys#do-the-right-thing
+						   id #t imp?
+						   (lambda (id* syntax?)
+						     (##sys#hash-table-update!
+						      ;; XXX FIXME: This is a bit of a hack.  Why is it needed at all?
+						      file-requirements
+						      (if syntax? 'dynamic/syntax 'dynamic)
+						      (lambda (lst)
+							(if (memq id* lst)
+							    lst
+							    (cons id* lst)))
+						      (lambda () (list id*)))))))
 				      (unless (or f
 						  (and (symbol? id)
 						       (or (feature? id)
diff --git a/csc.scm b/csc.scm
index 3beb6633..44c9f4dd 100644
--- a/csc.scm
+++ b/csc.scm
@@ -27,7 +27,7 @@
 
 (declare
   (block)
-  (uses data-structures utils files extras))
+  (uses data-structures eval utils files extras))
 
 (import chicken.data-structures
 	chicken.extras
diff --git a/csi.scm b/csi.scm
index f7a594d2..11743c5c 100644
--- a/csi.scm
+++ b/csi.scm
@@ -26,7 +26,7 @@
 
 
 (declare
-  (uses data-structures ports extras)
+  (uses data-structures eval extras ports)
   (usual-integrations)
   (disable-interrupts)
   (compile-syntax)
@@ -1053,9 +1053,6 @@ EOF
       (when (member* '("-w" "-no-warnings") args)
 	(unless quiet (display "Warnings are disabled\n"))
 	(set! ##sys#warnings-enabled #f) )
-      (unless quiet
-	(load-verbose #t)
-	(print-banner) )
       (when (member* '("-i" "-case-insensitive") args)
 	(unless quiet (display "Identifiers and symbols are case insensitive\n"))
 	(register-feature! 'case-insensitive)
@@ -1091,8 +1088,16 @@ EOF
 	(keyword-style #:none)
 	(parentheses-synonyms #f)
 	(symbol-escape #f) )
-      (unless (or (member* '("-n" "-no-init") args) script eval?) (loadinit))
-      (when batch 
+      ;; Load the the default modules into the evaluation environment.
+      ;; This is done before setting load-verbose => #t to avoid
+      ;; spurious import messages.
+      (eval '(import scheme chicken))
+      (unless quiet
+	(load-verbose #t)
+	(print-banner))
+      (unless (or (member* '("-n" "-no-init") args) script eval?)
+	(loadinit))
+      (when batch
 	(set! ##sys#notices-enabled #f))
       (do ([args args (cdr args)])
 	  ((null? args)
diff --git a/defaults.make b/defaults.make
index 81f1417e..85bfd270 100644
--- a/defaults.make
+++ b/defaults.make
@@ -271,7 +271,7 @@ PRIMITIVE_IMPORT_LIBRARIES = chicken srfi-4
 PRIMITIVE_IMPORT_LIBRARIES += csi setup-api setup-download
 POSIX_IMPORT_LIBRARY = posix
 FOREIGN_IMPORT_LIBRARY = foreign
-DYNAMIC_IMPORT_LIBRARIES = data-structures extras files irregex lolevel ports tcp utils
+DYNAMIC_IMPORT_LIBRARIES = data-structures eval extras files irregex lolevel ports tcp utils
 
 # targets
 
diff --git a/distribution/manifest b/distribution/manifest
index 879a23ff..58ed9135 100644
--- a/distribution/manifest
+++ b/distribution/manifest
@@ -240,6 +240,8 @@ chicken.import.scm
 chicken.import.c
 chicken.data-structures.import.scm
 chicken.data-structures.import.c
+chicken.eval.import.scm
+chicken.eval.import.c
 chicken.extras.import.scm
 chicken.extras.import.c
 chicken.files.import.scm
diff --git a/eval.scm b/eval.scm
index d0fe5bf2..9d03d75c 100644
--- a/eval.scm
+++ b/eval.scm
@@ -28,7 +28,6 @@
 (declare
   (unit eval)
   (uses expand modules)
-  (hide pds pdss pxss d) 
   (not inline ##sys#repl-read-hook ##sys#repl-print-hook 
        ##sys#read-prompt-hook ##sys#alias-global-hook ##sys#user-read-hook
        ##sys#syntax-error-hook))
@@ -49,9 +48,23 @@
 #define C_rnd_fix()		(C_fix(rand()))
 <#
 
+(module chicken.eval
+  (chicken-home define-reader-ctor dynamic-load-libraries
+   eval eval-handler extension-information
+   load load-library load-noisily load-relative load-verbose
+   interaction-environment null-environment scheme-report-environment
+   provide provided? repl repl-prompt require
+   repository-path set-dynamic-load-mode!)
+
+;; Exclude values defined within this module.
+(import (except scheme eval load interaction-environment null-environment scheme-report-environment))
+(import chicken chicken.foreign)
+
 (include "common-declarations.scm")
 (include "mini-srfi-1.scm")
 
+(register-feature! 'eval)
+
 (define-syntax d (syntax-rules () ((_ . _) (void))))
 
 
@@ -62,8 +75,7 @@
 (define-foreign-variable install-lib-name c-string "C_INSTALL_LIB_NAME")
 
 (define ##sys#core-library-modules
-  '(extras lolevel utils files tcp irregex posix srfi-4
-	   data-structures ports))
+  '(eval extras lolevel utils files tcp irregex posix srfi-4 data-structures ports))
 
 (define ##sys#core-syntax-modules
   '(chicken-syntax chicken-ffi-syntax))
@@ -720,12 +732,7 @@
 			  (compile '(##core#undefined) e #f tf cntr se) ]
 
 			 [(##core#declare)
-			  (if (memq #:compiling ##sys#features)
-			      ;; XXX FIXME: This is a bit of a hack.  Why is it needed at all?
-			      (for-each (lambda (d) (chicken.compiler.core#process-declaration d se)) (cdr x)) 
-			      (##sys#notice
-			       "declarations are ignored in interpreted code"
-			       x) )
+			  (##sys#notice "declarations are ignored in interpreted code" x)
 			  (compile '(##core#undefined) e #f tf cntr se) ]
 
 			 [(##core#define-inline ##core#define-constant)
@@ -949,6 +956,10 @@
 	(loop (##sys#slot mode 1)) ) )
     (##sys#set-dlopen-flags! now global) ) )
 
+(define load)
+(define load-noisily)
+(define load-relative)
+
 (let ([read read]
       [write write]
       [display display]
@@ -1165,7 +1176,7 @@
 		   (check (##sys#substring p 0 (fx- n 1))) ]
 		  [else p] ) ) ) ) ) ) )
 
-(define ##sys#repository-path
+(define repository-path
   (let ((rpath
 	 (if (##sys#fudge 22)		; private repository?
 	     (foreign-value "C_private_repository_path()" c-string)
@@ -1180,7 +1191,7 @@
 	  (set! rpath val)
 	  rpath))))
 
-(define repository-path ##sys#repository-path)
+(define ##sys#repository-path repository-path)
 
 (define ##sys#setup-mode #f)
 
@@ -1284,19 +1295,7 @@
 
 (define ##sys#do-the-right-thing
   (let ((vector->list vector->list))
-    (lambda (id comp? imp?)
-      (define (adjoin lst)
-	(if (memq id lst)
-	    lst
-	    (cons id lst)))
-      (define (add-req id syntax?)
-	(when comp?
-	  (##sys#hash-table-update!
-	   ;; XXX FIXME: This is a bit of a hack.  Why is it needed at all?
-	   chicken.compiler.core#file-requirements
-	   (if syntax? 'dynamic/syntax 'dynamic)
-	   adjoin
-	   (lambda () (list id)))))
+    (lambda (id comp? imp? #!optional (add-req void))
       (define (impform x id builtin?)
 	`(##core#begin
 	  ,x
@@ -1692,15 +1691,16 @@
 			       (##sys#read-error port "undefined sharp-comma constructor" spec) ) ) ) ) ) ) )
 	    (else (old char port)) ) ) ) )
 
+) ; eval module
 
 ;;; Simple invocation API:
 
 (declare
   (hide last-error run-safe store-result store-string
-	CHICKEN_yield CHICKEN_apply_to_string
-	CHICKEN_eval CHICKEN_eval_string CHICKEN_eval_to_string CHICKEN_eval_string_to_string
-	CHICKEN_apply CHICKEN_eval_apply CHICKEN_eval_to_string
-	CHICKEN_read CHICKEN_load CHICKEN_get_error_message) )
+	CHICKEN_yield CHICKEN_eval CHICKEN_eval_string
+	CHICKEN_eval_to_string CHICKEN_eval_string_to_string
+	CHICKEN_apply CHICKEN_apply_to_string CHICKEN_eval_apply
+	CHICKEN_read CHICKEN_load CHICKEN_get_error_message))
 	
 (define last-error #f)
 
@@ -1729,13 +1729,13 @@
 (define-external (CHICKEN_eval (scheme-object exp) ((c-pointer "C_word") result)) bool
   (run-safe
    (lambda ()
-     (store-result (eval exp) result) ) ) )
+     (store-result (chicken.eval#eval exp) result))))
 
 (define-external (CHICKEN_eval_string (c-string str) ((c-pointer "C_word") result)) bool
   (run-safe
    (lambda ()
-     (let ([i (open-input-string str)])
-       (store-result (eval (read i)) result)) )))
+     (let ((i (open-input-string str)))
+       (store-result (chicken.eval#eval (read i)) result)))))
 
 #>
 #define C_copy_result_string(str, buf, n)  (C_memcpy((char *)C_block_item(buf, 0), C_c_string(str), C_unfix(n)), ((char *)C_block_item(buf, 0))[ C_unfix(n) ] = '\0', C_SCHEME_TRUE)
@@ -1753,8 +1753,8 @@
   bool
   (run-safe
    (lambda ()
-     (let ([o (open-output-string)])
-       (write (eval exp) o) 
+     (let ((o (open-output-string)))
+       (write (chicken.eval#eval exp) o)
        (store-string (get-output-string o) bufsize buf)) ) ) )
 
 (define-external (CHICKEN_eval_string_to_string (c-string str) ((c-pointer "char") buf)
@@ -1762,8 +1762,8 @@
   bool
   (run-safe
    (lambda ()
-     (let ([o (open-output-string)])
-       (write (eval (read (open-input-string str))) o)
+     (let ((o (open-output-string)))
+       (write (chicken.eval#eval (read (open-input-string str))) o)
        (store-string (get-output-string o) bufsize buf)) ) ) )
 
 (define-external (CHICKEN_apply (scheme-object func) (scheme-object args) 
@@ -1776,18 +1776,18 @@
   bool
   (run-safe
    (lambda ()
-     (let ([o (open-output-string)])
+     (let ((o (open-output-string)))
        (write (apply func args) o) 
        (store-string (get-output-string o) bufsize buf)) ) ) )
 
 (define-external (CHICKEN_read (c-string str) ((c-pointer "C_word") result)) bool
   (run-safe
    (lambda ()
-     (let ([i (open-input-string str)])
+     (let ((i (open-input-string str)))
        (store-result (read i) result) ) ) ) )
 
 (define-external (CHICKEN_load (c-string str)) bool
-  (run-safe (lambda () (load str) #t)) )
+  (run-safe (lambda () (chicken.eval#load str) #t)))
 
 (define-external (CHICKEN_get_error_message ((c-pointer "char") buf) (int bufsize)) void
   (store-string (or last-error "No error") bufsize buf) )
diff --git a/modules.scm b/modules.scm
index 810c7022..241a88b0 100644
--- a/modules.scm
+++ b/modules.scm
@@ -26,6 +26,7 @@
 
 (declare
   (unit modules)
+  (uses eval)
   (disable-interrupts)
   (fixnum)
   (hide lookup merge-se module-indirect-exports)
@@ -304,7 +305,7 @@
 	(ifs (module-import-forms mod))
 	(sexports (module-sexports mod))
 	(mifs (module-meta-import-forms mod)))
-    `(,@(if (pair? ifs) `((eval '(import ,@(##sys#strip-syntax ifs)))) '())
+    `(,@(if (pair? ifs) `((chicken.eval#eval '(import ,@(##sys#strip-syntax ifs)))) '())
       ,@(if (pair? mifs) `((import ,@(##sys#strip-syntax mifs))) '())
       ,@(##sys#fast-reverse (map ##sys#strip-syntax (module-meta-expressions mod)))
       (##sys#register-compiled-module
@@ -891,12 +892,14 @@
 	     call-with-current-continuation input-port? output-port?
 	     current-input-port current-output-port call-with-input-file
 	     call-with-output-file open-input-file open-output-file
-	     close-input-port close-output-port load read eof-object? read-char
-	     peek-char write display write-char newline with-input-from-file
-	     with-output-to-file eval
+	     close-input-port close-output-port (load . chicken.eval#load)
+	     read read-char peek-char write display write-char newline eof-object?
+	     with-input-from-file with-output-to-file (eval . chicken.eval#eval)
 	     char-ready? imag-part real-part make-rectangular make-polar angle
 	     magnitude numerator denominator
-	     scheme-report-environment null-environment interaction-environment
+	     (scheme-report-environment . chicken.eval#scheme-report-environment)
+	     (null-environment . chicken.eval#null-environment)
+	     (interaction-environment . chicken.eval#interaction-environment)
 	     else))
       (r4rs-syntax
        ;;XXX better would be to move these into the "chicken"
diff --git a/rules.make b/rules.make
index bdf18862..8425226c 100644
--- a/rules.make
+++ b/rules.make
@@ -544,6 +544,7 @@ core.c: core.scm mini-srfi-1.scm \
 		chicken.compiler.scrutinizer.import.scm \
 		chicken.compiler.support.import.scm \
 		chicken.data-structures.import.scm \
+		chicken.eval.import.scm \
 		chicken.extras.import.scm
 optimizer.c: optimizer.scm mini-srfi-1.scm \
 		chicken.compiler.support.import.scm \
@@ -649,6 +650,8 @@ data-structures.c: data-structures.scm \
 		chicken.foreign.import.scm
 extras.c: extras.scm \
 		chicken.data-structures.import.scm
+eval.c: eval.scm \
+		chicken.foreign.import.scm
 files.c: files.scm \
 		chicken.data-structures.import.scm \
 		chicken.extras.import.scm \
@@ -678,7 +681,7 @@ bootstrap-lib = $(CHICKEN) $(call profile-flags, $@) $< $(CHICKEN_LIBRARY_OPTION
 library.c: $(SRCDIR)library.scm $(SRCDIR)banner.scm $(SRCDIR)common-declarations.scm
 	$(bootstrap-lib)
 eval.c: $(SRCDIR)eval.scm $(SRCDIR)common-declarations.scm $(SRCDIR)mini-srfi-1.scm
-	$(bootstrap-lib)
+	$(bootstrap-lib) -emit-import-library chicken.eval
 expand.c: $(SRCDIR)expand.scm $(SRCDIR)synrules.scm $(SRCDIR)common-declarations.scm
 	$(bootstrap-lib)
 modules.c: $(SRCDIR)modules.scm $(SRCDIR)common-declarations.scm $(SRCDIR)mini-srfi-1.scm
diff --git a/scrutinizer.scm b/scrutinizer.scm
index 490b41ea..dc5c2526 100644
--- a/scrutinizer.scm
+++ b/scrutinizer.scm
@@ -26,8 +26,7 @@
 
 (declare
   (unit scrutinizer)
-  (uses data-structures extras ports files
-	support) )
+  (uses data-structures eval extras ports files support))
 
 (module chicken.compiler.scrutinizer
     (scrutinize load-type-database emit-type-file
@@ -1788,7 +1787,7 @@
 
 ;;; type-db processing
 
-(define (load-type-database name specialize #!optional (path (repository-path)))
+(define (load-type-database name specialize #!optional (path (##sys#repository-path)))
   (define (clean! name)
     (when specialize (mark-variable name '##compiler#clean #t)))
   (define (pure! name)
diff --git a/support.scm b/support.scm
index b56cd477..dcb66f30 100644
--- a/support.scm
+++ b/support.scm
@@ -27,7 +27,7 @@
 
 (declare (unit support)
 	 (not inline ##sys#user-read-hook) ; XXX: Is this needed?
-	 (uses data-structures files extras ports) )
+	 (uses data-structures eval extras files ports))
 
 (module chicken.compiler.support
     (compiler-cleanup-hook bomb collected-debugging-output debugging
@@ -1588,7 +1588,7 @@
 ;;; Load support files
 
 (define (load-identifier-database name)	; Used only in batch-driver.scm
-  (and-let* ((rp (repository-path))
+  (and-let* ((rp (##sys#repository-path))
 	     (dbfile (file-exists? (make-pathname rp name))))
     (debugging 'p (sprintf "loading identifier database ~a ...~%" dbfile))
     (for-each
diff --git a/tests/posix-tests.scm b/tests/posix-tests.scm
index f2fd896e..95f2c846 100644
--- a/tests/posix-tests.scm
+++ b/tests/posix-tests.scm
@@ -33,12 +33,12 @@
 (assert-error (process-execute "false" '("123\x00456") '("foo\x00bar" "blabla") '("lalala" "qux\x00mooh")))
 
 (receive (in out pid)
-    (process "../csi" '("-n" "-e"
+    (process "../csi" '("-n" "-I" ".." "-e"
                         "(write 'err (current-error-port)) (write 'ok)"))
   (assert (equal? 'ok (read in))))
 
 (receive (in out pid err)
-    (process* "../csi" '("-n" "-e"
+    (process* "../csi" '("-n" "-I" ".." "-e"
                          "(write 'err (current-error-port)) (write 'ok)"))
   (assert (equal? 'ok (read in)))
   (assert (equal? 'err (read err))))
diff --git a/tests/scrutiny.expected b/tests/scrutiny.expected
index a73b8010..9c72dc76 100644
--- a/tests/scrutiny.expected
+++ b/tests/scrutiny.expected
@@ -1,4 +1,6 @@
 
+Note: assignment to imported value binding: car
+
 Note: in local procedure `c',
   in local procedure `b',
   in toplevel procedure `a':
@@ -40,17 +42,17 @@ Warning: at toplevel:
   (scrutiny-tests.scm:29) in procedure call to `+', expected argument #2 of type `number', but was given an argument of type `symbol'
 
 Warning: at toplevel:
-  assignment of value of type `fixnum' to toplevel variable `car' does not match declared type `(forall (a178) (procedure car ((pair a178 *)) a178))'
+  assignment of value of type `fixnum' to toplevel variable `car' does not match declared type `(forall (a183) (procedure car ((pair a183 *)) a183))'
 
 Warning: at toplevel:
-  expected in `let' binding of `g10' a single result, but were given 2 results
+  expected in `let' binding of `g15' a single result, but were given 2 results
 
 Warning: at toplevel:
-  in procedure call to `g10', expected a value of type `(procedure () *)', but was given a value of type `fixnum'
+  in procedure call to `g15', expected a value of type `(procedure () *)', but was given a value of type `fixnum'
 
 Note: in toplevel procedure `foo':
   expected value of type boolean in conditional but were given a value of type
-  `(procedure bar32 () *)' which is always true:
+  `(procedure bar37 () *)' which is always true:
 
 (if bar 3 (##core#undefined))
 
diff --git a/types.db b/types.db
index 1cc08385..979ebb63 100644
--- a/types.db
+++ b/types.db
@@ -752,7 +752,7 @@
 (open-output-file (#(procedure #:clean #:enforce) open-output-file (string #!rest symbol) output-port))
 (close-input-port (#(procedure #:enforce) close-input-port (input-port) undefined))
 (close-output-port (#(procedure #:enforce) close-output-port (output-port) undefined))
-(load (procedure load (string #!optional (procedure (*) . *)) undefined))
+(chicken.eval#load (procedure chicken.eval#load (string #!optional (procedure (*) . *)) undefined))
 (read (#(procedure #:enforce) read (#!optional input-port) *))
 
 (eof-object? (#(procedure #:pure #:predicate eof) eof-object? (*) boolean))
@@ -796,7 +796,7 @@
 			 (let ((#(tmp2) #(2)))
 			   (#(tmp2) (#(tmp1)))))))
 
-(eval (procedure eval (* #!optional (struct environment)) . *))
+(chicken.eval#eval (procedure chicken.eval#eval (* #!optional (struct environment)) . *))
 (char-ready? (#(procedure #:enforce) char-ready? (#!optional input-port) boolean))
 
 (real-part (#(procedure #:clean #:enforce #:foldable) real-part (number) (or integer float ratnum))
@@ -838,14 +838,14 @@
 	     ((integer) (fixnum) (let ((#(tmp) #(1))) '1))
 	     ((ratnum) (integer) (##sys#slot #(1) '2)))
 
-(scheme-report-environment 
- (#(procedure #:clean #:enforce) scheme-report-environment (#!optional fixnum) (struct environment)))
+(chicken.eval#scheme-report-environment
+ (#(procedure #:clean #:enforce) chicken.eval#scheme-report-environment (#!optional fixnum) (struct environment)))
 
-(null-environment
- (#(procedure #:clean #:enforce) null-environment (#!optional fixnum) (struct environment)))
+(chicken.eval#null-environment
+ (#(procedure #:clean #:enforce) chicken.eval#null-environment (#!optional fixnum) (struct environment)))
 
-(interaction-environment
- (#(procedure #:clean) interaction-environment () (struct environment)))
+(chicken.eval#interaction-environment
+ (#(procedure #:clean) chicken.eval#interaction-environment () (struct environment)))
 
 (port-closed? (#(procedure #:clean #:enforce) port-closed? (port) boolean)
 	      ((port) (##sys#slot #(1) '8)))
@@ -924,7 +924,7 @@
 (call/cc (#(procedure #:enforce) call/cc ((procedure (*) . *)) . *))
 (case-sensitive (#(procedure #:clean) case-sensitive (#!optional *) *))
 (char-name (#(procedure #:clean #:enforce) char-name ((or char symbol) #!optional char) *)) ;XXX -> (or char symbol) ?
-(chicken-home (#(procedure #:clean) chicken-home () string))
+(chicken.eval#chicken-home (#(procedure #:clean) chicken.eval#chicken-home () string))
 (chicken-version (#(procedure #:pure) chicken-version (#!optional *) string))
 (command-line-arguments (#(procedure #:clean) command-line-arguments (#!optional (list-of string)) (list-of string)))
 (condition-predicate (#(procedure #:clean #:enforce) condition-predicate (symbol) (procedure ((struct condition)) boolean)))
@@ -966,7 +966,7 @@
  (#(procedure #:clean) current-read-table (#!optional (struct read-table)) (struct read-table)))
 
 (current-seconds (#(procedure #:clean) current-seconds () integer))
-(define-reader-ctor (#(procedure #:clean #:enforce) define-reader-ctor (symbol procedure) undefined))
+(chicken.eval#define-reader-ctor (#(procedure #:clean #:enforce) chicken.eval#define-reader-ctor (symbol procedure) undefined))
 (delete-file (#(procedure #:clean #:enforce) delete-file (string) string))
 (enable-warnings (#(procedure #:clean) enable-warnings (#!optional *) *))
 
@@ -990,7 +990,7 @@
 (exit (procedure exit (#!optional fixnum) noreturn))
 (exit-handler (#(procedure #:clean #:enforce) exit-handler (#!optional (procedure (fixnum) . *)) procedure))
 (expand (procedure expand (* #!optional list) *))
-(extension-information (#(procedure #:clean) extension-information (symbol) *))
+(chicken.eval#extension-information (#(procedure #:clean) chicken.eval#extension-information (symbol) *))
 (feature? (#(procedure #:clean) feature? (#!rest symbol) boolean))
 (features (#(procedure #:clean) features () (list-of symbol)))
 (file-exists? (#(procedure #:clean #:enforce) file-exists? (string) (or false string)))
@@ -1182,9 +1182,9 @@
 (keyword->string (#(procedure #:clean #:enforce) keyword->string (symbol) string))
 (keyword-style (#(procedure #:clean) keyword-style (#!optional symbol) symbol))
 (keyword? (#(procedure #:pure) keyword? (*) boolean))
-(load-library (#(procedure #:enforce) load-library (symbol #!optional string) undefined))
-(load-relative (#(procedure #:enforce) load-relative (string #!optional (procedure (*) . *)) undefined))
-(load-verbose (#(procedure #:clean) load-verbose (#!optional *) *))
+(chicken.eval#load-library (#(procedure #:enforce) chicken.eval#load-library (symbol #!optional string) undefined))
+(chicken.eval#load-relative (#(procedure #:enforce) chicken.eval#load-relative (string #!optional (procedure (*) . *)) undefined))
+(chicken.eval#load-verbose (#(procedure #:clean) chicken.eval#load-verbose (#!optional *) *))
 (machine-byte-order (#(procedure #:pure) machine-byte-order () symbol))
 (machine-type (#(procedure #:pure) machine-type () symbol))
 
@@ -1234,10 +1234,10 @@
 (register-feature! (#(procedure #:clean #:enforce) register-feature! (#!rest symbol) undefined))
 (remprop! (#(procedure #:clean #:enforce) remprop! (symbol symbol) undefined))
 (rename-file (#(procedure #:clean #:enforce) rename-file (string string) string))
-(repl (#(procedure #:enforce) repl (#!optional (procedure (*) . *)) undefined))
-(repl-prompt (#(procedure #:clean #:enforce) repl-prompt (#!optional (procedure () string)) procedure))
-(repository-path (#(procedure #:clean) repository-path (#!optional *) *))
-(require (#(procedure #:clean) require (#!rest (or string symbol)) undefined))
+(chicken.eval#repl (#(procedure #:enforce) chicken.eval#repl (#!optional (procedure (*) . *)) undefined))
+(chicken.eval#repl-prompt (#(procedure #:clean #:enforce) chicken.eval#repl-prompt (#!optional (procedure () string)) procedure))
+(chicken.eval#repository-path (#(procedure #:clean) chicken.eval#repository-path (#!optional *) *))
+(chicken.eval#require (#(procedure #:clean) chicken.eval#require (#!rest (or string symbol)) undefined))
 (reset (procedure reset () noreturn))
 (reset-handler (#(procedure #:clean #:enforce) reset-handler (#!optional (procedure () . *)) procedure))
 (return-to-host (procedure return-to-host () . *))
Trap