[plt-scheme] 3D boxes and macros

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Tue Jul 19 18:43:42 EDT 2005

Arjun Guha wrote:
> I have a box defined in the transformer environment, that I insert into 
> the syntax.  I'd expect that the set-box! would first mutate the 
> contents to 'outer-value, followed by the call to unbox.  


Is this what you want?

(module box-and-macro mzscheme

   (define-for-syntax the-box (box 'initial))

   (define-syntax (my-macro stx)
     (syntax-case stx ()
       [(_)
        #`(begin
            (begin-for-syntax
              (set-box! the-box 'value))
            (if (eq? (unbox #,the-box) 'value)
                'okay
                'fail))])))

-- 
Jens Axel Søgaard



Posted on the users mailing list.