[plt-scheme] ifndef in PLT?

From: Dmitry Lizorkin (lizorkin at ispras.ru)
Date: Thu Oct 6 01:40:51 EDT 2005


At macro-expansion time, I need to determine whether a given identifier is
defined. I failed to find any standard PLT facility for this purpose in the

I thought of the following solution:

(require (lib "defmacro.ss"))

; Return `body' if `id' is not defined
(define-macro (ifndef id body)
      (((lambda (x) #t)
        (lambda (x) `,body)))
    (eval id)

 (define (string-upcase str) ...))

It works; however, I do not like calling `eval' in the macro body.
Could you suggest a more elegant solution?

Thank you,

Posted on the users mailing list.