[plt-scheme] is dynamic-require or namespace used here?
I am browsing through the help desk trying to find a function that could
be used here. Imagine a program structured like this
(require (lib "RealLib.ss"))
(require (lib "MyLib.ss"))
(uni-Do-This)
(uni-Do-That)
(uni-And-The-Other)
where RealLib and MyLib are basically identical libraries consisting of
functions Do-This, Do-That, And-The-Other.
What I want to do is right when the program is executed it asks the user
via read which library they want to use for the program. If the user
types RealLib then MzScheme/DrScheme would effectively compile the program
as if the code were written like this
(require (prefix uni- (lib "RealLib.ss")))
(require (lib "MyLib.ss"))
(uni-Do-This)
(uni-Do-That)
(uni-And-The-Other)
If the user typed in MyLib then the code would compile like this
(require (lib "RealLib.ss"))
(require (prefix uni- (lib "MyLib.ss")))
(uni-Do-This)
(uni-Do-That)
(uni-And-The-Other)
I am looking at things like (dynamic-require) and namespaces
but they are a bit hard to understand and I don't know if any of these are
what I am looking for. I thought namespace-require might work but I
don't know how to get it to accept the words prefix and lib in the
expression. Or if all of this is even possible.
The explanation behind all of this is say I have a lib RealLib and I want
to write my own version of the library with my own code, MyLib, but I want
to keep all the procedure names the same. In order to test if my library
works, I would write a test program, write universal procedure calls and
then dynamically call which library I want the procedures to load from
*without changing the code in the test program* In other words, I can
debug my library by first running the test program with the real library
and then running it with my library to compare the output and I can do
this without altering the code of the test program.
Thanks for any assistance.