(module parameter mzscheme
(require
(file "base.ss")
)
(provide
(all-defined)
)
(define (make-guard pred type-message)
(lambda (val)
(if (pred val)
val
(raise-exn/format exn:fail:unlib
"Expected ~a, received ~a" type-message val))))
(define-syntax (define-parameter stx)
(syntax-case stx ()
[(_ parameter-name initial-value guard with-form)
(syntax
(begin
(define parameter-name
(make-parameter initial-value guard))
(define-syntax (with-form stx)
(syntax-case stx ()
[(with-form new-value exp (... ...))
(syntax
(parameterize ([parameter-name new-value])
exp (... ...)))]))))]))
)