On 2017-10-14 22:40, Peter Bex wrote:
OK, now I know for sure why we didn't do that before: it causes a panic..
This has something to do with the ordering of the requirements and what
they define in which order.  So, I've enhanced the comment a bit to
explain and removed the extra requirement in this new patch.

Yeah, that's exactly the situation: library needs scheme and eval needs
library, so scheme can't need eval. I think that's a very low priority
issue, though, so for right now eval is just an implicit dependency of
scheme.

Anyway, I think adding entries to the "core-unit-overrides" list isn't
the right approach for these modules. I know I set that example by
putting "scheme" there, but that was left over from my attempts to work
around the aforementioned circular dependency. The overrides list is
really only necessary for modules that do something "special", such as
depending on a unit for-syntax (in fact, that's the _only_ case for
which the list is used at the moment).

So, because these rnrs modules (and scheme, currently) all load either
zero or one unit at runtime (that is to say, they don't do anything
"special"), instead of adding them to the overrides list I think we
should just add unit information to their module records and treat them
like any other module. See the attached patch.

Cheers,

Evan
>From e7ed3aa99b6895194493e7df52591348839294c2 Mon Sep 17 00:00:00 2001
From: Evan Hanson <[email protected]>
Date: Mon, 16 Oct 2017 08:21:39 +1300
Subject: [PATCH] Add unit dependency info to the scheme and rnrs[-null]
 modules

The r4rs module depends on the "library" unit, so we add that dependency
to its module registration in modules.scm.

The r[45]rs-null modules don't depend on any unit since they only export
syntax, so set their module-library slots to #f to indicate "no unit".

The scheme module only depends on the "library" unit, so remove it from
the list of `core-unit-requirements` and add "library" to its module
registration so that it's treated like any other unit.

Add a test to make sure the r4rs and r4-null libraries are working.
---
 eval.scm               |  6 +++---
 modules.scm            | 10 +++++-----
 tests/module-tests.scm | 12 ++++++++++++
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/eval.scm b/eval.scm
index 10162865..dbdab377 100644
--- a/eval.scm
+++ b/eval.scm
@@ -894,10 +894,10 @@
 (define-foreign-variable install-lib-name c-string "C_INSTALL_LIB_NAME")
 (define-foreign-variable uses-soname? bool "C_USES_SONAME")
 
+;;; Core unit information
+
 (define-constant core-unit-requirements
-  '((scheme ; XXX not totally correct, also needs eval
-     . (##core#require library))
-    (chicken.foreign
+  '((chicken.foreign
      . (##core#require-for-syntax chicken-ffi-syntax))
     (chicken.condition
      . (##core#begin
diff --git a/modules.scm b/modules.scm
index f71519b6..8d99a0f4 100644
--- a/modules.scm
+++ b/modules.scm
@@ -941,13 +941,13 @@
        ;;    ##sys#initial-macro-environment and thus always available inside 
        ;;    modules.
        ##sys#default-macro-environment))
-  (##sys#register-primitive-module 'r4rs r4rs-values r4rs-syntax)
-  (##sys#register-primitive-module 
-   'scheme
+  (##sys#register-core-module 'r4rs 'library r4rs-values r4rs-syntax)
+  (##sys#register-core-module
+   'scheme 'library
    (append '(dynamic-wind values call-with-values) r4rs-values)
    r4rs-syntax)
-  (##sys#register-primitive-module 'r4rs-null '() r4rs-syntax)
-  (##sys#register-primitive-module 'r5rs-null '() r4rs-syntax))
+  (##sys#register-core-module 'r4rs-null #f '() r4rs-syntax)
+  (##sys#register-core-module 'r5rs-null #f '() r4rs-syntax))
 
 (##sys#register-module-alias 'r5rs 'scheme)
 (##sys#register-module-alias 'srfi-88 'chicken.keyword)
diff --git a/tests/module-tests.scm b/tests/module-tests.scm
index e6969e76..12d63bc4 100644
--- a/tests/module-tests.scm
+++ b/tests/module-tests.scm
@@ -10,6 +10,18 @@
 
 (test-begin "modules")
 
+(test-assert
+ "r4rs"
+ (module test-r4rs ()
+   (import r4rs)
+   (equal? 1 1)))
+
+(test-assert
+ "r4rs-null"
+ (module test-r4rs-null ()
+   (import r4rs-null)
+   (begin #t)))
+
 (test-equal "internal/variable"
 (module foo (abc def)
   (import scheme)
-- 
2.11.0

_______________________________________________
Chicken-hackers mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to