May be you need this:
(define-macro (define-at-expand-time-and-runtime . body) (eval `(define ,@body)) `(define ,@body))
(define-at-expand-time-and-runtime global "foo")
(define-macro (magic name value) `(define ,(string->symbol (string-append global "-" name)) ,value))
(magic "bar" 1)
foo-bar
1
Vasil
Suppose I have the following:
(define global "foo")
(define-macro (magic ...))
(magic "bar" 1); <-- I want this to expand to (define foo-bar 1)
How can I make this happen? The macro needs to access the value of "global", but it can't at compile time; if the macro outputs some code that takes advantage of things at run time, I can get to:
(define (string->symbol (string-append "foo" "-" "bar")) 1)
but this, of course, tries to define a function string->symbol rather than what I want.
Thanks! _______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list