Skip to content

Commit

Permalink
Merge pull request #85 from dpk/srfi-139
Browse files Browse the repository at this point in the history
Support SRFI 139
  • Loading branch information
arcfide authored Nov 17, 2023
2 parents 32e5592 + 623887f commit 9c4bbbf
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions %3a139.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!r6rs
(library (srfi :139)
(export define-syntax-parameter syntax-parameterize)
(import (srfi :139 impl)))
31 changes: 31 additions & 0 deletions %3a139/impl.chezscheme.sls
Original file line number Diff line number Diff line change
@@ -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 ...))))))))))

0 comments on commit 9c4bbbf

Please sign in to comment.