From 6e6bc619a517ef44b1e16299b741754eb4033413 Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Thu, 14 Dec 2017 22:16:30 +0100 Subject: [PATCH 2/3] Drop weird macro workarounds in favour of chicken.internal.syntax Instead of jumping through hoops to avoid referring to syntactic exports from modules we've just defined (but without macros) in library.scm, we just import all macros from chicken.internal.syntax. --- library.scm | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/library.scm b/library.scm index 2049ef42..2a32eea5 100644 --- a/library.scm +++ b/library.scm @@ -182,18 +182,14 @@ EOF ;; NOTE: Modules defined here will typically exclude syntax ;; definitions, those are handled by expand.scm or modules.scm. ;; Handwritten import libraries (or a special-case module in -;; modules.scm for scheme) contains the value exports merged with +;; modules.scm for scheme) contain the value exports merged with ;; syntactic exports. The upshot of this is that any module that ;; refers to another module defined *earlier* in this file cannot use ;; macros from the earlier module! - -;; We get around that problem for now by using "chicken" when -;; importing things like "when", "unless" from chicken.base, -;; "handle-exceptions" from chicken.condition. For "scheme" there's a -;; workaround available: we import r5rs-null which contains only the -;; syntactic definitions from r5rs and reexport it straight away in -;; this file, so that we may use at least the scheme definitions -;; normally. For other modules, this still is a major TODO! +;; +;; We get around this problem by using the "chicken.internal.syntax" +;; module, which is baked in and exports *every* available core macro. +;; See modules.scm, expand.scm and chicken-syntax.scm for details. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Pre-declaration of scheme, so it can be used later on. We only use @@ -247,10 +243,7 @@ EOF eval interaction-environment null-environment scheme-report-environment load) -;; We use r5rs-null to get just the syntax exports for "scheme", -;; because importing them from "scheme" would be importing then from -;; the module currently being defined, which is initially empty.... -(import r5rs-null) +(import chicken.internal.syntax) ;; See note above ;;; Operations on booleans: @@ -604,7 +597,7 @@ EOF on-exit exit exit-handler implicit-exit-handler emergency-exit ) -(import scheme (only chicken when unless)) +(import scheme chicken.internal.syntax) (define (fixnum? x) (##core#inline "C_fixnump" x)) (define (flonum? x) (##core#inline "C_i_flonump" x)) @@ -1306,9 +1299,7 @@ EOF (import scheme) (import chicken.foreign) (import (only chicken.base flonum?)) -;; TODO: Importing these from chicken.base won't work due to -;; incomplete chicken.base definition above -(import (only chicken when unless define-inline)) +(import chicken.internal.syntax) (define maximum-flonum (foreign-value "DBL_MAX" double)) (define minimum-flonum (foreign-value "DBL_MIN" double)) @@ -4859,12 +4850,9 @@ EOF condition condition? condition->list condition-predicate condition-property-accessor get-condition-property) -(import scheme) -(import chicken.fixnum) -(import chicken.foreign) -(import (only chicken get-call-chain print-call-chain when unless - get-output-string open-output-string let-optionals - make-parameter)) +(import scheme chicken.base chicken.fixnum chicken.foreign) +(import (only chicken get-output-string open-output-string)) +(import chicken.internal.syntax) (define (##sys#signal-hook mode msg . args) (##core#inline "C_dbg_hook" #f) @@ -5722,7 +5710,7 @@ EOF (import scheme) (import chicken.base chicken.fixnum chicken.foreign) -(import (only chicken when unless handle-exceptions)) +(import chicken.internal.syntax) ;;; GC info: @@ -5935,7 +5923,7 @@ EOF (import scheme) (import (only (chicken base) getter-with-setter)) -(import (only chicken when)) +(import chicken.internal.syntax) (define (put! sym prop val) (##sys#check-symbol sym 'put!) @@ -6069,7 +6057,7 @@ EOF (import scheme) (import chicken.fixnum chicken.foreign chicken.keyword) (import (only chicken get-environment-variable make-parameter)) -(import (only chicken when unless define-constant)) +(import chicken.internal.syntax) (define software-type (let ((sym (string->symbol ((##core#primitive "C_software_type"))))) -- 2.11.0