[plt-scheme] List of definitions provided by a module

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Tue Sep 26 06:20:53 EDT 2006

Dave Gurnell skrev:
> Hello all,
> 
> Apologies for the duplication. Someone somewhere back in this list asked 
> if there was an easy way to get a list of the definitions provided by a 
> module. Unfortunately I can't find the original email to see if anyone 
> had a response.
> 
> This is for me to analyse some code I'm writing. I have a bunch of 
> modules that require one another and re-provide some definitions:
...
> I want to get a list of the definitions that are being provided by 
> module-c (including those from module-a and module-b). In practice, of 
> course, the code is a bit larger than this, and there are two or three 
> layers of recursion in the provides/requires.

Here is a quick solution.

(module module-a mzscheme
   (provide a b c)
   (define a 'a)
   (define b 'b)
   (define c 'c))

(module module-b mzscheme
   (provide d e f)
   (define d 'd)
   (define e 'e)
   (define f 'f))

(module module-c mzscheme
   (require module-a
            module-b)
   (provide (all-from module-a)
            (all-from module-b)
            g h i)
   (define g 'g)
   (define h 'h)
   (define i 'i))

(module empty mzscheme
   (provide #%module-begin
            (rename require #%require)
            (rename provide #%provide)))

(module dummy empty
   (#%require module-c)
   (#%provide (all-from module-c)))

(require dummy)

(namespace-mapped-symbols (module->namespace 'dummy))


-- 
Jens Axel Søgaard



Posted on the users mailing list.