Subject: Re: Can't assign a module name with getenv/2

From: Jan Wielemaker <[email-masked]>
Date: Mon, 7 Jun 1999 10:54:18 +0200

On Sun, 06 Jun 1999, Jean-Francois Rompre wrote:
>Hello,
>
>I would be grateful for any advice with the following 
>problem.
>
>In my load file, I use getenv to obtain the search path
>used to make it possible to call use_module as follows:
>
>	use_module( util( util)),
>	use_module( interface( history)),
>	etc...
>
>However, when I try to obtain the module name itself, e.g.
>display( prt), from a stored env. variable, the system can't find it.
>When I instead  use 'display( prt)' in hardcoded form , everything
>works like a charm.
>
>In other words, I am trying to do this: create the variable DPY in
>a shell script :
>	...
>	DPY="display( prt)";export DPY
>	...
>	< pl command>
>
>
>which then starts prolog with the application loading
>file and the initialization clause. The intialization clause then
>creates an exception when 
>	...
>	getenv( 'DPY',  DisplayModule),
>	use_module( DisplayModule ),	
>	 ...
>But when I replace the above two statements  with
>
>	....
>	use_module( display( prt)	),
>	....
>it compiles without any error message.

getenv/2 yields an atom, so the getenv version is essentially

	use_module('display(prt)'),

Which of course won't work.  See atom_to_term/3 or term_to_atom/2 to
convert the atom into a term.

	Regards --- Jan