From a877627231608cfecea5a789062a0d1bd2ba670c Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Tue, 12 Jun 2018 20:10:50 -0700 Subject: [PATCH] Define parameterize using syntax-rules and add it to the host adapter. --- src/runtime/host-adapter.scm | 8 ++++++++ src/runtime/mit-macros.scm | 24 ++++++------------------ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/runtime/host-adapter.scm b/src/runtime/host-adapter.scm index 28572f67b..a3b7b3873 100644 --- a/src/runtime/host-adapter.scm +++ b/src/runtime/host-adapter.scm @@ -102,6 +102,14 @@ USA. (delay-force (make-promise expression)))))) env)) + (if (unbound? env 'parameterize) + (eval '(define-syntax parameterize + (syntax-rules () + ((parameterize ((param value) ...) form ...) + (parameterize* (list (cons param value) ...) + (lambda () form ...))))) + env)) + (if (unbound? env 'define-print-method) (eval '(define (define-print-method predicate print-method) unspecific) diff --git a/src/runtime/mit-macros.scm b/src/runtime/mit-macros.scm index e3041528e..c96542ee9 100644 --- a/src/runtime/mit-macros.scm +++ b/src/runtime/mit-macros.scm @@ -187,24 +187,6 @@ USA. (apply scons-begin (map scons-set! ids vals)) (scons-call (apply scons-lambda '() body-forms))))))))) -(define $parameterize - (spar-transformer->runtime - (delay - (scons-rule - `((subform (* (subform (list id any)))) - (+ any)) - (lambda (bindings body-forms) - (let ((ids (map car bindings)) - (vals (map cadr bindings))) - (scons-call (scons-close 'parameterize*) - (apply scons-call - (scons-close 'list) - (map (lambda (id val) - (scons-call (scons-close 'cons) id val)) - ids - vals)) - (apply scons-lambda '() body-forms)))))))) - ;;; SRFI 2: and-let* ;;; The SRFI document is a little unclear about the semantics, imposes @@ -406,6 +388,12 @@ USA. ((delay expression) (delay-force (make-promise expression))))) +(define-syntax $parameterize + (syntax-rules () + ((parameterize ((param value) ...) form ...) + (parameterize* (list (cons param value) ...) + (lambda () form ...))))) + (define $guard (spar-transformer->runtime (delay -- 2.25.1