~ chicken-core (chicken-5) 139deae0eb6525f10cdd904bc9641dd254e945f5


commit 139deae0eb6525f10cdd904bc9641dd254e945f5
Author:     Peter Bex <peter@more-magic.net>
AuthorDate: Fri Nov 24 22:43:41 2017 +0100
Commit:     felix <felix@call-with-current-continuation.org>
CommitDate: Wed Dec 13 11:31:32 2017 +0100

    Make default imports consistent between interpreter and compiler
    
    This moves default-(syntax-)imports are moved from c-platform.scm into
    internal.scm so that it can be found by csi.scm as well.
    
    The imports are changed to scheme, chicken.base and chicken.syntax
    in order to prepare for eventual removal of the "chicken" module.
    Tests are changed to import the needed modules now that "chicken"
    isn't in the default modules anymore.
    
    Signed-off-by: felix <felix@call-with-current-continuation.org>

diff --git a/c-platform.scm b/c-platform.scm
index d6773552..6803db64 100644
--- a/c-platform.scm
+++ b/c-platform.scm
@@ -27,13 +27,11 @@
 
 (declare
   (unit c-platform)
-  (uses data-structures
-	optimizer support compiler))
+  (uses data-structures internal optimizer support compiler))
 
 (module chicken.compiler.c-platform
     (;; Batch compilation defaults
-     default-declarations default-profiling-declarations
-     default-units default-imports default-syntax-imports
+     default-declarations default-profiling-declarations default-units
 
      ;; Compiler flags
      valid-compiler-options valid-compiler-options-with-argument
@@ -45,7 +43,8 @@
 	chicken.data-structures
 	chicken.compiler.optimizer
 	chicken.compiler.support
-	chicken.compiler.core)
+	chicken.compiler.core
+	chicken.internal)
 
 (include "tweaks")
 (include "mini-srfi-1.scm")
@@ -76,8 +75,6 @@
        ##sys#profile-entry ##sys#profile-exit) ) ) )
 
 (define default-units '(library eval))
-(define default-imports '(scheme chicken chicken.base))
-(define default-syntax-imports '(scheme chicken chicken.base))
 
 (define words-per-flonum 4)
 
diff --git a/csi.scm b/csi.scm
index 665bf5db..15a9cdf1 100644
--- a/csi.scm
+++ b/csi.scm
@@ -1068,8 +1068,8 @@ EOF
       ;; Load the the default modules into the evaluation environment.
       ;; This is done before setting load-verbose => #t to avoid
       ;; spurious import messages.
-      (eval '(import-for-syntax scheme chicken))
-      (eval '(import scheme chicken))
+      (eval `(import-for-syntax ,@default-syntax-imports))
+      (eval `(import ,@default-imports))
       (unless quiet
 	(load-verbose #t)
 	(print-banner))
diff --git a/internal.scm b/internal.scm
index 812f77e1..5df9e561 100644
--- a/internal.scm
+++ b/internal.scm
@@ -51,7 +51,10 @@
 
     ;; Low-level hash table support
     hash-table-ref hash-table-set! hash-table-update!
-    hash-table-for-each hash-table-size)
+    hash-table-for-each hash-table-size
+
+    ;; Modules that are made available to code by default
+    default-imports default-syntax-imports)
 
 (import scheme chicken)
 
@@ -204,4 +207,9 @@
 	size
 	(loop len (fx+ bkt 1) (fx+ size (##sys#length (##sys#slot ht bkt)))))))
 
+;;; Modules that are made available to code by default:
+
+(define default-imports '(scheme chicken.base chicken.syntax))
+(define default-syntax-imports '(scheme chicken.base chicken.syntax))
+
 ) ; chicken.internal
diff --git a/rules.make b/rules.make
index d8fecb0a..168ae1fd 100644
--- a/rules.make
+++ b/rules.make
@@ -527,7 +527,8 @@ c-platform.c: c-platform.scm mini-srfi-1.scm \
 		chicken.compiler.optimizer.import.scm \
 		chicken.compiler.support.import.scm \
 		chicken.compiler.core.import.scm \
-		chicken.data-structures.import.scm
+		chicken.data-structures.import.scm \
+		chicken.internal.import.scm
 c-backend.c: c-backend.scm mini-srfi-1.scm \
 		chicken.compiler.c-platform.import.scm \
 		chicken.compiler.support.import.scm \
diff --git a/tests/apply-test.scm b/tests/apply-test.scm
index 45cd65fe..9c05e1c4 100644
--- a/tests/apply-test.scm
+++ b/tests/apply-test.scm
@@ -1,5 +1,8 @@
 (import (chicken format)
-        (chicken platform))
+        (chicken platform)
+	(chicken fixnum))
+
+(import-for-syntax (chicken fixnum))
 
 (define (list-tabulate n proc)
   (let loop ((i 0))
diff --git a/tests/arithmetic-test.scm b/tests/arithmetic-test.scm
index 496060d7..ed2600bc 100644
--- a/tests/arithmetic-test.scm
+++ b/tests/arithmetic-test.scm
@@ -15,9 +15,11 @@
   (else))
 
 
-(import (chicken platform)
+(import (chicken condition)
+	(chicken platform)
 	(chicken pretty-print)
-	(chicken random))
+	(chicken random)
+	(chicken fixnum))
 
 (define range 2)
 (define random-range 32000)
diff --git a/tests/condition-tests.scm b/tests/condition-tests.scm
index 5a9789b2..207b6231 100644
--- a/tests/condition-tests.scm
+++ b/tests/condition-tests.scm
@@ -1,3 +1,4 @@
+(import (chicken condition))
 
 (define condition1 (make-property-condition 'exn 'message "foo" 'arguments '("bar") 'location 'test))
 (define condition2 (make-property-condition 'sam 'age 23 'partner "max"))
diff --git a/tests/environment-tests.scm b/tests/environment-tests.scm
index c7d87d9b..b4143a52 100644
--- a/tests/environment-tests.scm
+++ b/tests/environment-tests.scm
@@ -1,5 +1,6 @@
 ;;;; environment-tests.scm
 
+(import (chicken load))
 
 (load-relative "test.scm")
 
diff --git a/tests/fft.scm b/tests/fft.scm
index 99b85f58..3f00e38f 100644
--- a/tests/fft.scm
+++ b/tests/fft.scm
@@ -9,7 +9,7 @@
      (block)
      (not safe)))
   (else
-   (import chicken.bitwise chicken.flonum)))
+   (import chicken.bitwise chicken.fixnum chicken.flonum)))
 
 ;;; All the following redefinitions are *ignored* by the Gambit compiler
 ;;; because of the declarations above.
diff --git a/tests/functor-tests.scm b/tests/functor-tests.scm
index e9e3351f..7a9f71b1 100644
--- a/tests/functor-tests.scm
+++ b/tests/functor-tests.scm
@@ -1,7 +1,7 @@
 ;;;; functor-tests.scm
 
 
-(import data-structures chicken.port chicken.pretty-print)
+(import data-structures chicken.fixnum chicken.port chicken.pretty-print)
 
 
 (include "test.scm")
diff --git a/tests/library-tests.scm b/tests/library-tests.scm
index 1b62ad19..bf1164e1 100644
--- a/tests/library-tests.scm
+++ b/tests/library-tests.scm
@@ -1,6 +1,7 @@
 ;;;; library-tests.scm
 
-(import chicken.blob chicken.bitwise chicken.flonum chicken.keyword chicken.port)
+(import chicken.blob chicken.bitwise chicken.fixnum chicken.flonum
+	chicken.keyword chicken.port chicken.condition)
 
 (define-syntax assert-fail
   (syntax-rules ()
diff --git a/tests/locative-stress-test.scm b/tests/locative-stress-test.scm
index eb53a971..e5d160e9 100644
--- a/tests/locative-stress-test.scm
+++ b/tests/locative-stress-test.scm
@@ -2,6 +2,8 @@
 
 (declare (usual-integrations))
 
+(import (chicken fixnum))
+
 ;(set-gc-report! #t)
 
 #>
diff --git a/tests/loopy-test.scm b/tests/loopy-test.scm
index 9a0f99d2..46b94c1c 100644
--- a/tests/loopy-test.scm
+++ b/tests/loopy-test.scm
@@ -1,5 +1,6 @@
 (import (only chicken.format printf)
-        (only chicken.time current-milliseconds))
+        (only chicken.time current-milliseconds)
+	chicken.load)
 
 (load-relative "loopy-loop.scm")
 (load-relative "matchable.scm")
diff --git a/tests/match-test.scm b/tests/match-test.scm
index 20568bfa..38540309 100644
--- a/tests/match-test.scm
+++ b/tests/match-test.scm
@@ -1,3 +1,5 @@
+(import (chicken load))
+
 (load-relative "test.scm")
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
diff --git a/tests/module-tests.scm b/tests/module-tests.scm
index e972db9b..0901ea19 100644
--- a/tests/module-tests.scm
+++ b/tests/module-tests.scm
@@ -1,6 +1,6 @@
 ;;;; module-tests.scm
 
-(import (chicken eval))
+(import (chicken eval) (chicken load))
 
 (cond-expand
  (compiling
diff --git a/tests/numbers-test-gauche.scm b/tests/numbers-test-gauche.scm
index b38f4770..314c5e1b 100644
--- a/tests/numbers-test-gauche.scm
+++ b/tests/numbers-test-gauche.scm
@@ -48,7 +48,7 @@
 
 ;; Gauche compat
 
-(import (chicken bitwise) (chicken port) (chicken format) (chicken string))
+(import (chicken bitwise) (chicken port) (chicken format) (chicken string) (chicken fixnum))
 
 (define (greatest-fixnum) most-positive-fixnum)
 (define (least-fixnum) most-negative-fixnum)
diff --git a/tests/numbers-test.scm b/tests/numbers-test.scm
index 4d7e3499..81be61e2 100644
--- a/tests/numbers-test.scm
+++ b/tests/numbers-test.scm
@@ -3,6 +3,7 @@
 (include "test.scm")
 
 (import (chicken bitwise)
+	(chicken fixnum)
         (chicken flonum)
         (chicken format)
         (chicken platform)
diff --git a/tests/private-repository-test.scm b/tests/private-repository-test.scm
index 7ee00319..5db6544d 100644
--- a/tests/private-repository-test.scm
+++ b/tests/private-repository-test.scm
@@ -2,6 +2,7 @@
 
 
 (import (chicken pathname)
+	(chicken platform)
         (chicken posix))
 
 (define read-symbolic-link*
diff --git a/tests/r7rs-tests.scm b/tests/r7rs-tests.scm
index 3faeec50..22488edf 100644
--- a/tests/r7rs-tests.scm
+++ b/tests/r7rs-tests.scm
@@ -1,6 +1,7 @@
 ;; R7RS Tests
 
-(import (only (chicken port) with-input-from-string with-output-to-string))
+(import (only (chicken port) with-input-from-string with-output-to-string)
+	(chicken condition))
 
 ;; Copied from R4RS tests
 (define cur-section '())
diff --git a/tests/scrutiny.expected b/tests/scrutiny.expected
index 44afef85..1caf8ea6 100644
--- a/tests/scrutiny.expected
+++ b/tests/scrutiny.expected
@@ -43,10 +43,10 @@ Warning: at toplevel:
   assignment of value of type `fixnum' to toplevel variable `scheme#car' does not match declared type `(forall (a) (procedure scheme#car ((pair a *)) a))'
 
 Warning: at toplevel:
-  expected a single result in `let' binding of `g19', but received 2 results
+  expected a single result in `let' binding of `g39', but received 2 results
 
 Warning: at toplevel:
-  in procedure call to `g19', expected a value of type `(procedure () *)' but was given a value of type `fixnum'
+  in procedure call to `g39', expected a value of type `(procedure () *)' but was given a value of type `fixnum'
 
 Note: in toplevel procedure `foo':
   expected a value of type boolean in conditional, but was given a value of type `(procedure bar () *)' which is always true:
diff --git a/tests/test-finalizers-2.scm b/tests/test-finalizers-2.scm
index d30e039e..7d244f9e 100644
--- a/tests/test-finalizers-2.scm
+++ b/tests/test-finalizers-2.scm
@@ -1,6 +1,6 @@
 ;;;; test-finalizers-2.scm - test finalizers + GC roots
 
-(import (chicken gc))
+(import (chicken gc) (chicken fixnum))
 
 (define (list-tabulate n proc)
   (let loop ((i 0))
diff --git a/tests/typematch-tests.scm b/tests/typematch-tests.scm
index d78199b9..6b09b7e3 100644
--- a/tests/typematch-tests.scm
+++ b/tests/typematch-tests.scm
@@ -2,7 +2,7 @@
 
 
 (import (only chicken.data-structures identity)
-        chicken.blob chicken.memory chicken.locative)
+        chicken.blob chicken.condition chicken.memory chicken.locative)
 
 
 (define (make-list n x)
Trap