;;; Syntax2.scheme
;;; Copyright Ó 1988, 1989, 1991 by Xerox Corporation. All rights reserved.
;;; Last changed by Pavel on August 11, 1989 4:18:39 pm PDT
;;; Michael Plass, January 21, 1989 0:05:43 am PST
;;; Cedar Scheme Derived Expressions
;;; Binding Forms
;; Obsolete:
(extend-syntax (fluid-let)
( (fluid-let ((var val) ...)
body
more-body ...)
(with (((saved-var ...) (map (lambda (x) (gensym)) '(var ...)))
(swap! (gensym))
(temp (gensym)))
(let ((saved-var val) ... (temp #f))
(let ((swap! (lambda ()
{ (set! temp var)
(set! var saved-var)
(set! saved-var temp)
} ...)))
(dynamic-wind
swap!
(lambda () body more-body ...)
swap!))))))
;;; Conditionals
(extend-syntax (when)
( (when predicate body more ...)
(if predicate (begin body more ...))))
(extend-syntax (unless)
( (unless predicate body more ...)
(if (not predicate) (begin body more ...))))
;;; Syntax Extension
(extend-syntax (macro)
( (macro name proc)
(with ((var (gensym)))
(define name
(make-syntax
(lambda var
(proc (cons 'name var))))))))
;;; Simple Modularity
(extend-syntax (export)
((export (var ...) defn ...)
(begin
(define var #f) ...
(let ((lst (let () defn ... (list var ...))))
{ (set! var (car lst))
(set! lst (cdr lst))} ...)
'(var ...))))