diff --git a/%3a139.sls b/%3a139.sls new file mode 100644 index 0000000..21b7ed2 --- /dev/null +++ b/%3a139.sls @@ -0,0 +1,4 @@ +#!r6rs +(library (srfi :139) + (export define-syntax-parameter syntax-parameterize) + (import (srfi :139 impl))) diff --git a/%3a139/impl.chezscheme.sls b/%3a139/impl.chezscheme.sls new file mode 100644 index 0000000..587be3b --- /dev/null +++ b/%3a139/impl.chezscheme.sls @@ -0,0 +1,31 @@ +(library (srfi :139 impl) + (export define-syntax-parameter + syntax-parameterize) + (import (chezscheme) + (srfi :213)) + + (define-syntax syntax-parameter? (syntax-rules ())) + (define-syntax define-syntax-parameter + (syntax-rules () + ((_ name default-transformer) + (begin + (define-syntax name default-transformer) + (define-property name syntax-parameter? #t))))) + + (define-syntax syntax-parameterize + (lambda (stx) + (capture-lookup + (lambda (lookup) + (syntax-case stx () + ((_ ((name new-transformer) ...) body_0 body_1 ...) + (cond ((find (lambda (n) + (not (lookup n #'syntax-parameter?))) + #'(name ...)) + => (lambda (n) + (syntax-violation 'syntax-parameterize + "identifier is not bound to a syntax parameter" + stx + n))) + (else + #'(fluid-let-syntax ((name new-transformer) ...) + body_0 body_1 ...))))))))))