chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] [PATCH 1/1] Move `module-environment' into chicken.eva


From: Evan Hanson
Subject: [Chicken-hackers] [PATCH 1/1] Move `module-environment' into chicken.eval
Date: Sat, 17 Jun 2017 12:32:20 +1200

To align more closely with R7RS's library organisation, we put the
`module-environment' procedure in the "chicken.eval" module.

Also, drop the [undocumented] second argument from the user-facing
version of this procedure, and remove it from the plain "chicken"
module. The dropped argument is still used internally, but doesn't need
to be part of the public API.
---
 chicken.import.scm          |  1 -
 eval.scm                    | 20 ++++++++++++++------
 modules.scm                 |  2 +-
 tests/environment-tests.scm |  2 ++
 tests/module-tests.scm      |  1 +
 types.db                    |  3 ++-
 6 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/chicken.import.scm b/chicken.import.scm
index 3ebc9c9d..3b20bb7a 100644
--- a/chicken.import.scm
+++ b/chicken.import.scm
@@ -130,7 +130,6 @@
    make-parameter
    make-promise
    (make-property-condition . chicken.condition#make-property-condition)
-   module-environment
    (most-negative-fixnum . chicken.fixnum#most-negative-fixnum)
    (most-positive-fixnum . chicken.fixnum#most-positive-fixnum)
    nan?
diff --git a/eval.scm b/eval.scm
index 8167774f..2c62136e 100644
--- a/eval.scm
+++ b/eval.scm
@@ -45,8 +45,10 @@
 <#
 
 (module chicken.eval
-  (eval eval-handler
-   interaction-environment null-environment scheme-report-environment)
+  (eval-handler module-environment
+
+   ;; TODO These should only be exported by the scheme module (and r4rs/r5rs):
+   eval interaction-environment null-environment scheme-report-environment)
 
 ;; Exclude bindings defined within this module.
 (import (except scheme eval interaction-environment null-environment 
scheme-report-environment)
@@ -752,6 +754,12 @@
   (apply (eval-handler) x env))
 
 
+;;; User-facing `module-environment` procedure:
+
+(define (module-environment name)
+  (chicken.module#module-environment name))
+
+
 ;;; Setting properties dynamically scoped
 
 (define-values (##sys#put/restore! ##sys#with-property-restore)
@@ -812,10 +820,10 @@
 (define scheme-report-environment)
 (define null-environment)
 
-(let* ((r4s (module-environment 'r4rs 'scheme-report-environment/4))
-       (r5s (module-environment 'scheme 'scheme-report-environment/5))
-       (r4n (module-environment 'r4rs-null 'null-environment/4))
-       (r5n (module-environment 'r5rs-null 'null-environment/5)))
+(let* ((r4s (chicken.module#module-environment 'r4rs 
'scheme-report-environment/4))
+       (r5s (chicken.module#module-environment 'scheme 
'scheme-report-environment/5))
+       (r4n (chicken.module#module-environment 'r4rs-null 'null-environment/4))
+       (r5n (chicken.module#module-environment 'r5rs-null 
'null-environment/5)))
   (define (strip se)
     (foldr
      (lambda (s r)
diff --git a/modules.scm b/modules.scm
index 0b818904..637eda0c 100644
--- a/modules.scm
+++ b/modules.scm
@@ -1057,7 +1057,7 @@
 
 (register-feature! 'module-environments)
 
-(define (module-environment mname #!optional (ename mname))
+(define (chicken.module#module-environment mname #!optional (ename mname))
   (let ((mod (find-module/import-library mname 'module-environment)))
     (if (not mod)
        (##sys#syntax-error-hook
diff --git a/tests/environment-tests.scm b/tests/environment-tests.scm
index 285ad65e..61f50f03 100644
--- a/tests/environment-tests.scm
+++ b/tests/environment-tests.scm
@@ -33,6 +33,8 @@
 (test-equal 1 (eval '(if #t 1 2) (null-environment 5)))
 (test-equal (eval '((lambda (x) x) 123) (null-environment 5)) 123)
 
+(import (chicken eval))
+
 (define baz 100)
 
 (module foo (bar)
diff --git a/tests/module-tests.scm b/tests/module-tests.scm
index 421560e6..e6969e76 100644
--- a/tests/module-tests.scm
+++ b/tests/module-tests.scm
@@ -1,5 +1,6 @@
 ;;;; module-tests.scm
 
+(import (chicken eval))
 
 (cond-expand
  (compiling
diff --git a/types.db b/types.db
index 07258c46..dfc1d0bf 100644
--- a/types.db
+++ b/types.db
@@ -862,6 +862,8 @@
 (chicken.eval#interaction-environment
  (#(procedure #:clean) chicken.eval#interaction-environment () (struct 
environment)))
 
+(chicken.eval#module-environment
+ (#(procedure #:clean #:enforce) chicken.eval#module-environment ((or symbol 
(list-of (or symbol fixnum)))) (struct environment)))
 
 ;; chicken
 
@@ -1266,7 +1268,6 @@
 (chicken.flonum#minimum-flonum float)
 (chicken.fixnum#most-negative-fixnum fixnum)
 (chicken.fixnum#most-positive-fixnum fixnum)
-(module-environment (#(procedure #:clean #:enforce) module-environment ((or 
symbol (list-of (or symbol fixnum))) #!optional *) (struct environment)))
 (on-exit (#(procedure #:clean #:enforce) on-exit ((procedure () . *)) 
undefined))
 (open-input-string (#(procedure #:clean #:enforce) open-input-string (string 
#!rest) input-port))
 (open-output-string (#(procedure #:clean) open-output-string (#!rest) 
output-port))
-- 
2.11.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]