[plt-scheme] Recognizing datums in macros
Consider:
(define-syntax (define-constant-setter stx)
(syntax-case stx ()
[(define-constant-setter name! datum)
#'(define-syntax (name! stx) ()
(syntax-case stx ()
[(name! var)
#'(begin (set! var datum)
datum)]))]))
(define-constant-setter null! '())
(define-constant-setter zero! 0)
(define-constant-setter one! 1)
(define-constant-setter infinite! +inf.0)
(define-constant-setter minus-infinite! -inf.0)
(define-constant-setter empty-vector! #())
With the intended usage:
> (define foo 42)
> (null! foo)
()
> foo
()
Is there a way to signal an error if datum is not a datum?
--
Jens Axel Søgaard