[plt-scheme] Parameterized modules

From: Filipe Cabecinhas (filcab at gmail.com)
Date: Sun May 3 12:35:27 EDT 2009

Hi,

How can I parameterize a module?
For example, I have module A, which depends on a module that implements 
B. When I (require A), I want to be able to tell it which of the B 
implementations I want to use. This is useful when you have several 
backends and a frontend. I have a frontend that is available as 
macros/functions to a scheme program. When I (require A), I want to be 
able to tell it to use B1 or B2, for example:

a.scm:
#lang scheme
(define a ()
   (+ (b) 42))

b1.scm:
#lang scheme
(define b ()
   1)

b2.scm:
#lang scheme
(define b ()
   2)


Then I want to use it:
client.scm:
#lang scheme
(require-parameterized a b1) ;; or b2
...


Can I do something like this? What if B also uses A's functions?


Regards,

   Filipe


Posted on the users mailing list.