Hi Dan,

Try with this:

main.rkt:

#lang racket
(require racket/stxparam "macro.rkt" "param.rkt")
(syntax-parameterize ([dirs 123])
  (mymacro))

macro.rkt:

#lang racket
(require racket/stxparam "param.rkt")
(provide mymacro)
(define-syntax (mymacro stx)
  #`(printf "dirs was ~a\n" #,(syntax-parameter-value #'dirs)))

param.rkt:

#lang racket
(require racket/stxparam)
(provide dirs)
(define-syntax-parameter dirs #f)


If you want the parameter's value to be effective during the require itself, 
like this:

(splicing-syntax-parameterize ([dirs 123])
  (require "myfile.rkt"))

then I do not know of an easy solution. You can set a compile-time variable to 
a mutable box, and set! that box, but it has some shortcomings:
1) when the file reading from the box is first compiled, the box has its 
default value
2) changes to the value are no longer scoped (every set-box! overwrites the 
value, so transitive requires might not see the value you expected if there are 
several calls to set-box!).

Here's the code for that:

main.rkt

#lang racket
(require racket/stxparam
         racket/splicing
         "param.rkt")

(begin-for-syntax
  (set-box! dirs 123))
(require "myfile.rkt")

myfile.rkt:

#lang racket
(require racket/stxparam
         "w3.rkt")
(begin-for-syntax
  (printf "dirs is ~a\n" dirs))


param.rkt:

#lang racket
(require racket/stxparam)
(provide (for-syntax dirs))
(define-for-syntax dirs (box #f))

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to