Hello,

These two patches move `begin-for-syntax' and `require-extension-for-syntax'
out of the default macro environment, effectively dropping them from (scheme)
and putting them in (chicken base) instead.

I think this leaves only `require-library' to move, rename, or remove from the
default macro environment. Exactly which option we should choose is a subject
for another email, I think.

Cheers,

Evan
>From 4aebe30fb9a974c1b48ecf73ea6abb3a4e3d2851 Mon Sep 17 00:00:00 2001
From: Evan Hanson <[email protected]>
Date: Tue, 17 Oct 2017 18:54:02 +1300
Subject: [PATCH 1/2] Move `begin-for-syntax' out of the default macro
 environment

This moves the `begin-for-syntax' form out of expand.scm and into
chicken-syntax.scm so that it isn't in the default macro environment,
but rather part of (chicken base).
---
 chicken-syntax.scm      |  8 ++++++++
 eval.scm                |  1 -
 expand.scm              | 12 ++----------
 tests/module-tests.scm  |  2 +-
 tests/scrutiny.expected |  4 ++--
 5 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/chicken-syntax.scm b/chicken-syntax.scm
index afe62229..3abda348 100644
--- a/chicken-syntax.scm
+++ b/chicken-syntax.scm
@@ -267,6 +267,14 @@
   (let ((me0 (##sys#macro-environment)))
 
 (##sys#extend-macro-environment
+ 'begin-for-syntax '()
+ (##sys#er-transformer
+  (lambda (x r c)
+    (##sys#check-syntax 'begin-for-syntax x '(_ . #(_ 0)))
+    (##sys#register-meta-expression `(##core#begin ,@(cdr x)))
+    `(##core#elaborationtimeonly (##core#begin ,@(cdr x))))))
+
+(##sys#extend-macro-environment
  'define-constant
  '()
  (##sys#er-transformer
diff --git a/eval.scm b/eval.scm
index 37c5d8ca..983caa33 100644
--- a/eval.scm
+++ b/eval.scm
@@ -835,7 +835,6 @@
 		   require-extension
 		   require-extension-for-syntax
 		   require-library
-		   begin-for-syntax
 		   export
 		   module
 		   cond-expand
diff --git a/expand.scm b/expand.scm
index 1c66a01f..2482c92c 100644
--- a/expand.scm
+++ b/expand.scm
@@ -997,20 +997,12 @@
 		       `(##core#require ,lib ,(module-requirement name)))))
 	       (cdr x)))))))
 
-;; TODO Move this out of the initial environment:
-(##sys#extend-macro-environment
- 'begin-for-syntax '()
- (##sys#er-transformer
-  (lambda (x r c)
-    (##sys#check-syntax 'begin-for-syntax x '(_ . #(_ 0)))
-    (##sys#register-meta-expression `(##core#begin ,@(cdr x)))
-    `(##core#elaborationtimeonly (##core#begin ,@(cdr x))))))
-
 (##sys#extend-macro-environment
  'import-for-syntax '()
  (##sys#er-transformer
   (lambda (x r c)
-    `(,(r 'begin-for-syntax) (,(r 'import) ,@(cdr x))))))
+    (##sys#register-meta-expression `(,(r 'import) ,@(cdr x)))
+    `(##core#elaborationtimeonly (,(r 'import) ,@(cdr x))))))
 
 ;; The "initial" macro environment, containing only import forms
 (define ##sys#initial-macro-environment (##sys#macro-environment))
diff --git a/tests/module-tests.scm b/tests/module-tests.scm
index 33a4b15e..e34cce4a 100644
--- a/tests/module-tests.scm
+++ b/tests/module-tests.scm
@@ -225,7 +225,7 @@
 (test-equal
  "local module alias scope"
  (module m21 ()
-   (import scheme)
+   (import scheme chicken)
    (begin-for-syntax ; XXX s.a.
      (##sys#register-module-alias 'm18 'm19))
    (import m18)
diff --git a/tests/scrutiny.expected b/tests/scrutiny.expected
index 0495a6e6..d8c3b8fb 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 `car' does not match declared type `(forall (a) (procedure car ((pair a *)) a))'
 
 Warning: at toplevel:
-  expected a single result in `let' binding of `g20', but received 2 results
+  expected a single result in `let' binding of `g19', but received 2 results
 
 Warning: at toplevel:
-  in procedure call to `g20', expected a value of type `(procedure () *)' but was given a value of type `fixnum'
+  in procedure call to `g19', 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:
-- 
2.11.0

>From e0f252fe4af7582803e9234dad6fa6156c574202 Mon Sep 17 00:00:00 2001
From: Evan Hanson <[email protected]>
Date: Tue, 17 Oct 2017 18:54:02 +1300
Subject: [PATCH 2/2] Move `require-extension-for-syntax' out of the default
 macro environment

Also, update and sort the list of identifiers to be filtered when
constructing the rnrs[-null] environments in eval.scm, which had gone
out of date with recent changes (3a5150e0, 58bc3769 and a647d9ed).
---
 chicken-syntax.scm |  7 +++++++
 eval.scm           | 20 +++++++++++---------
 expand.scm         |  6 ------
 3 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/chicken-syntax.scm b/chicken-syntax.scm
index 3abda348..ca0dcdfb 100644
--- a/chicken-syntax.scm
+++ b/chicken-syntax.scm
@@ -1171,6 +1171,13 @@
   (lambda (x r c)
     `(,(r 'import) ,@(cdr x)))))
 
+(##sys#extend-macro-environment
+ 'require-extension-for-syntax
+ '()
+ (##sys#er-transformer
+  (lambda (x r c)
+    `(,(r 'begin-for-syntax) (,(r 'require-extension) ,@(cdr x))))))
+
 (##sys#macro-subset me0 ##sys#default-macro-environment)))
 
 
diff --git a/eval.scm b/eval.scm
index 983caa33..0426e644 100644
--- a/eval.scm
+++ b/eval.scm
@@ -828,18 +828,20 @@
     (foldr
      (lambda (s r)
        (if (memq (car s)
-		 '(import
-		   import-syntax
+		 '(cond-expand
+		   define-interface
+		   delay-force
+		   export
+		   functor
+		   import
 		   import-for-syntax
+		   import-syntax
 		   import-syntax-for-syntax
-		   require-extension
-		   require-extension-for-syntax
-		   require-library
-		   export
+		   letrec*
 		   module
-		   cond-expand
-		   syntax
-		   reexport))
+		   reexport
+		   require-library
+		   syntax))
 	   r
 	   (cons s r)))
      '()
diff --git a/expand.scm b/expand.scm
index 2482c92c..b2044d9a 100644
--- a/expand.scm
+++ b/expand.scm
@@ -1612,12 +1612,6 @@
 		     `(##core#require ,lib ,(module-requirement name)))))
 	     (cdr x))))))
 
-(##sys#extend-macro-environment
- 'require-extension-for-syntax
- '()
- (##sys#er-transformer
-  (lambda (x r c)
-    `(,(r 'begin-for-syntax) (,(r 'require-extension) ,@(cdr x))))))
 
 ;;; syntax-rules
 
-- 
2.11.0

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

Reply via email to