[plt-scheme] putenv / modules / extentions

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Jul 29 00:33:10 EDT 2003

At Mon, 28 Jul 2003 15:54:44 -0400, Alexander Friedman wrote:
> I have a scheme extention that relies on a specific environment variable to be 
> set for it's underlying c code to work correctly. If i call (putenv ...)
> outside the module before requiring it, everything works fine. However, 
> calling 
> putenv inside the module has no effect. Obviosly, the user of the module 
> should 
> not need to be aware of this detail. 
> 
> To be more specific, the the C library in question needs to load some font 
> files. It first looks in the directory it was run from, and then in a 
> directory 
> specified by the environment variable. Any ideas/suggestions/workarounds?

One option is to use `dynamic-require' after the `putenv' call. If you only need a few bindings from the C module, then

  (putenv ...)
  (define x1 (dynamic-require <path> 'x1))
  (define x2 (dynamic-require <path> 'x2))
  ...
  (define xn (dynamic-require <path> 'xn))

might work ok.

The general problem with `dynamic-require' is that it hides a part of
the module tree from module-traversing tools. But such tools generally
have to give up when they run into C-implemented modules, anyway.

Matthew




Posted on the users mailing list.