[plt-scheme] Recognizing datums in macros

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Tue Feb 7 18:16:36 EST 2006

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




Posted on the users mailing list.