From 9fea5f07af5465432262ee25c6df105b8b29614b Mon Sep 17 00:00:00 2001 From: Joe Marshall Date: Mon, 6 Jul 2015 13:01:55 -0700 Subject: [PATCH] Add CONS-STREAM* and CIRCULAR-STREAM macros. --- src/runtime/mit-macros.scm | 23 +++++++++++++++++++++++ src/runtime/runtime.pkg | 2 ++ 2 files changed, 25 insertions(+) diff --git a/src/runtime/mit-macros.scm b/src/runtime/mit-macros.scm index a99db4161..5e47f7115 100644 --- a/src/runtime/mit-macros.scm +++ b/src/runtime/mit-macros.scm @@ -571,6 +571,17 @@ USA. (else (ill-formed-syntax form)))))) +(define-syntax :circular-stream + (er-macro-transformer + (lambda (form rename compare) + compare ;ignore + (syntax-check '(KEYWORD EXPRESSION * EXPRESSION) form) + (let ((self (make-synthetic-identifier 'SELF))) + `(,(rename 'LETREC) ((,self (,(rename 'CONS-STREAM*) + ,@(cdr form) + ,self))) + ,self))))) + (define-syntax :cons-stream (er-macro-transformer (lambda (form rename compare) @@ -578,6 +589,18 @@ USA. (syntax-check '(KEYWORD EXPRESSION EXPRESSION) form) `(,(rename 'CONS) ,(cadr form) (,(rename 'DELAY) ,(caddr form)))))) + +(define-syntax :cons-stream* + (er-macro-transformer + (lambda (form rename compare) + compare ;ignore + (cond ((syntax-match? '(EXPRESSION EXPRESSION) (cdr form)) + `(,(rename 'CONS-STREAM) ,(cadr form) ,(caddr form))) + ((syntax-match? '(EXPRESSION * EXPRESSION) (cdr form)) + `(,(rename 'CONS-STREAM) ,(cadr form) + (,(rename 'CONS-STREAM*) ,@(cddr form)))) + (else + (ill-formed-syntax form)))))) (define-syntax :define-integrable (er-macro-transformer diff --git a/src/runtime/runtime.pkg b/src/runtime/runtime.pkg index 656e729d4..03df60fe0 100644 --- a/src/runtime/runtime.pkg +++ b/src/runtime/runtime.pkg @@ -4828,9 +4828,11 @@ USA. (assert :assert) (begin0 :begin0) (case :case) + (circular-stream :circular-stream) (cond :cond) (cond-expand :cond-expand) (cons-stream :cons-stream) + (cons-stream* :cons-stream*) (define :define) (define-integrable :define-integrable) (define-record-type :define-record-type) -- 2.25.1