[plt-scheme] dynamic require

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Jun 2 21:48:09 EDT 2005

At Fri, 03 Jun 2005 00:08:45 +0200, Hans Oesterholt-Dijkema wrote:
> (define load
>   (cond
>    ((string=? driver "oracle")
>     "sqld-oracle.scm")
>    ((string=? driver "sqlite")
>     "sqld-sqlite.scm")
>    ((string=? driver "psql")
>     "sqld-psql.scm")
>    (else
>     (error "DRIVER unknown"))))
> (require load)
> Is this somehow possible in mzscheme?

If you know the answer at compile time, you can use a macro, but I'm
guessing that you need a dynamic choice.

Dynamically, if you only need to extract a few values, you can use
`dynamic-require'. Alternately, package each driver into a unit and
dynamically select the one to invoke.

If you're working at the top level, I suppose that you could use
`eval' or `namespace-require', but I would avoid those.


Posted on the users mailing list.