[plt-scheme] Tricks with eval and namespaces
At Mon, 1 Aug 2005 15:30:56 -0400 (EDT), Arjun Guha wrote:
> (module ill-typed-expressions mzscheme
> [...]
> (test/error
> #'((define foo
> (+ #t 43)))))
>
> However, when test/error evaluates, we get:
>
> ../../../../../../../u/garjun/.plt-scheme/299.106/collects/dungeon/r5rs/r5rs-
> tinfer.ss:40:11:
> define-types-cgen: bad syntax in: (define-types-cgen (define-values (foo)
> (+ #t 43)))
>
> The custom language doesn't bind define to anything, so we are vaguely
> surprised that define is getting expanded to define-values.
The expression quoted with #' resides in a module that imports
`define', and #' preserves that context.
I think you want to strip all lexical context from the argument to
`test/error'. If you don't need source locations, then just use
#,@(syntax-object->datum stx)
in place of
#, at stx
If you need to keep source location, then you'll need a traversal that
uses `syntax-e' and `(datum->syntax-object #f ....)'.
Matthew