[plt-scheme] namespace-attach-module and sharing modules between evals

From: Danny Yoo (dyoo at hkn.eecs.berkeley.edu)
Date: Tue Jun 6 11:40:55 EDT 2006

Hi everyone,

The following three modules is a small test case I'm building to better 
understand namespace-attach-module:


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(module brick mzscheme
   (define-struct brick (a b))
   (provide (struct brick (a b)))
   (printf "brick.ss is invoked~n"))


(module evaluation mzscheme
   (provide (all-defined))

   (define (module-path->symbol module-path)
     ((current-module-name-resolver) module-path #f #f))

   (define (make-evaluation-namespace)
     (let ([ns (make-namespace)]
           [main-ns (current-namespace)])
       (parameterize ([current-namespace ns])
         (namespace-attach-module main-ns
                                  (module-path->symbol "brick.ss")
                                  ns)
         ns))))



(module test-evaluation mzscheme
   (require "evaluation.ss"
            "brick.ss")
   (define my-ns (make-evaluation-namespace)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



Unfortunately, it doesn't work; when I invoke the test-evaluation module, 
I see the following:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
brick.ss is invoked
evaluation.ss::323: namespace-attach-module: a different module with 
the same name is already in the destination namespace, for name: 
|,/home/dyoo/brick|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


This disturbs me a lot, because I'm taking most of this from web-server; 
(lib "configuration.ss" "web-server") appears to do the same kind of 
tricks here in the-make-server-namespace, and I'm not yet seeing why what 
I'm doing here is different.  I've tested this under both DrScheme and 
mzscheme 3.01.15-svn22may2006, as well as mzscheme 301-stable.


Any help would be greatly appreciated.  Thank you!


Posted on the users mailing list.