>From 4aebe30fb9a974c1b48ecf73ea6abb3a4e3d2851 Mon Sep 17 00:00:00 2001 From: Evan Hanson 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