[plt-scheme] eval and namespaces question
John W. Small writes:
>
> I'd like to define values within a module context using eval:
>
> (module foo mzscheme
> (eval '(define x 1)))
>
> and require them in another module:
>
> (module bar mzscheme
> (require foo)
> x ; error: expand: unbound variable x
> )
This may be a silly answer, but how about:
(eval '(module foo mzscheme
(define x 1)
(provide x)))
By the way, I think expressions in a module body are only evaluated
for side-effect, so just putting `x' in the body won't do anything.
But you can re-provide its value:
(module bar mzscheme
(require foo)
(define y x)
(provide y))
> (require bar)
> y
1
--dougo at ccs.neu.edu