[plt-scheme] "compile time" action of macros

From: Sam TH (samth at ccs.neu.edu)
Date: Mon Mar 19 08:07:12 EDT 2007

On 3/19/07, Chris Wright <chris.wright at southernhealth.org.au> wrote:
> Hi,
>
> I can achieve the desired effect (doing a calculation before run-time) with:
>
> (define-macro (bloop x)
>  (let ((y (add1 x)))
>    `(list ,y)))
>
> is there a way to do with with syntax-case? (I should, of course, ask
> "How do I do that with syntax case... :)

Untested:

(define-syntax (bloop stx)
  (syntax-case stx ()
    [(_ x) (let ([y (add1 (syntax-e #'x))])
               #`(list #,y))]))

sam th


-- 
sam th
samth at ccs.neu.edu


Posted on the users mailing list.