[plt-scheme] Unable to expand to a correct prefix in macro...
Hi all -
at the risk of beating this point (
http://list.cs.brown.edu/pipermail/plt-scheme/2007-April/017471.html) to
death, I've found that a possible issue is that my macro doesn't seem to do
what I expected... namely add an automatic prefix to a required lib. Any
pointers are greatly appreciated.
What I am trying to write...
(require-prefix (lib "test.ss" "test"))
Which should expand out to
(require (prefix test.test.ss: (lib "test.ss" "test")))
But it isn't working... I've simplify the test code to add a static prefix
(a:) rather than automatically generating a prefix but still have issues - I
thought with-syntax would ensure the prefix gets expanded with the correct
syntax-info, but there must be other points that I don't understand that
currently escaped me on why this macro doesn't work...
(define-syntax require-prefix
(lambda (stx)
(syntax-case stx ()
((_ req-clause)
(with-syntax ((pref (datum->syntax-object stx (string->symbol
"a:"))))
#`(require (prefix pref req-clause))))
((_ req-clause rest ...)
#'(begin
(_ req-clause)
(_ rest ...))))))
;; REPL
> (require-prefix (lib "string.scm" "util"))
> a:substr
Error. reference to undefined identifier: a:substr
> (require (prefix a: (lib "string.scm" "util")))
> a:substr
#<procedure:substr>
Thanks,
yinso
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20070424/3963a9e1/attachment.html>