[plt-scheme] define-for-meta

From: Jon Rafkind (rafkind at cs.utah.edu)
Date: Thu Feb 19 15:12:20 EST 2009

I would like to write a macro that can be used inside begin-for-syntax, 
but so far the only way I can do it is by putting the macro in a 
different file and (require (for-syntax "x.ss")) on that file. Is there 
something akin to (define-for-meta ...) so that I can define my syntax 
at meta phase 2 and hopefully achieve the same thing?

The following won't work unless `bar' is moved to 'y.ss' (and uncomment 
y.ss). There is no real need to do this other than keeping definitions 
all in the same file.

#lang scheme/base

(require (for-syntax
           ;; "y.ss"

(define-syntax bar
  (syntax-rules ()
    ((_ x)
     (+ 1 x))))
  (define (foo)
    (let ([x 1])
      (printf "foo ~a\n" (bar x))))


Posted on the users mailing list.