[plt-scheme] Copying modules between namespaces
--- Robby Findler <robby at cs.uchicago.edu> wrote:
> For list-related administrative tasks:
>
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> You wrote:
>
> (parameterize ([current-namespace eval-space])
> (namespace-attach-module ... (resolver ...)))
>
> You need:
>
> (define x (resolver ...))
> (parameterize ([current-namespace eval-space])
> (namespace-attach-module ... x))
>
For the benefit of future programmers searching the
archive, it isn't enough to attach the modules, they
then need to be required as well:
(require (lib "xml.ss" "webit")
(lib "html.ss" "webit"))
(define-syntax with-namespace
(syntax-rules ()
((_ space expr ...)
(parameterize ((current-namespace space))
expr ...))))
(define default-space (current-namespace))
(define default-resolver
(current-module-name-resolver))
(define eval-space (make-namespace 'initial))
(define eval-resolver
(parameterize ((current-namespace eval-space))
(current-module-name-resolver)))
(define (initialise-eval-space)
(define xml (default-resolver '(lib "xml.ss"
"webit") 'xml #f))
(define html (default-resolver '(lib "html.ss"
"webit") 'html #f))
; Initialise the namespace with the WebIt libraries
(with-namespace
eval-space
(namespace-attach-module
default-space
xml)
(namespace-attach-module
default-space
html)
(namespace-require '(lib "xml.ss" "webit"))
(namespace-require '(lib "html.ss" "webit"))))
Noel
=====
Email: noelwelsh <at> yahoo <dot> com
Jabber: noelw <at> jabber <dot> org
__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/