From: Cory Spencer
Subject: Accessing Environment Variables
Date: 
Message-ID: <9pu2te$c91$1@nntp.itservices.ubc.ca>
Hello -

I'm somewhat new to Lisp (by somewhat, I mean entirely) and I've tried to
no avail to find a method for accessing environment variables from within
my Lisp programs, but haven't been able to.  (Environment variables being
variables defined in the command line environment before I start up the
Lisp interpreter.)  Anyone possibly point me in the right direction here?

Thanks for any help,

Cory

From: JP Massar
Subject: Re: Accessing Environment Variables
Date: 
Message-ID: <3bc297c5.88267170@news>
On 9 Oct 2001 05:45:18 GMT, Cory Spencer <········@interchange.ubc.ca>
wrote:

>Hello -
>
>I'm somewhat new to Lisp (by somewhat, I mean entirely) and I've tried to
>no avail to find a method for accessing environment variables from within
>my Lisp programs, but haven't been able to.  (Environment variables being
>variables defined in the command line environment before I start up the
>Lisp interpreter.)  Anyone possibly point me in the right direction here?
>
>Thanks for any help,
>
 
That would depend entirely on the Lisp product you were using, and
possibly the OS you were running under.  Such access is not defined
in the language itself.

Using Allegro Common Lisp on Windows (and, I presume, Unix)

(system:getenv "PATH")

works.

Using Lispworks on Windows, I just found the function

lispworks:environment-variable

which works the same way.  I found it using the APROPOS function.
Presumably it is documented in their vendor-specific documentation
stuff, but I haven't looked.

Hope this helps.
From: Cory Spencer
Subject: Re: Accessing Environment Variables
Date: 
Message-ID: <9pu6du$dun$1@nntp.itservices.ubc.ca>
JP Massar <······@alum.mit.edu> wrote:

> That would depend entirely on the Lisp product you were using, and
> possibly the OS you were running under.  Such access is not defined
> in the language itself.

That would do it, thanks. :)

Cory

(And it was the Gnu Common Lisp implementation running under Linux.)
From: Thomas F. Burdick
Subject: Re: Accessing Environment Variables
Date: 
Message-ID: <xcvsnct9sdl.fsf@conquest.OCF.Berkeley.EDU>
Cory Spencer <········@interchange.ubc.ca> writes:

> JP Massar <······@alum.mit.edu> wrote:
> 
> > That would depend entirely on the Lisp product you were using, and
> > possibly the OS you were running under.  Such access is not defined
> > in the language itself.
> 
> That would do it, thanks. :)
> 
> Cory
> 
> (And it was the Gnu Common Lisp implementation running under Linux.)

Just so you know, GCL is not an ANSI CL (the modern dialect), it's an
implementation of an older version of Common Lisp.  Unless you have
some particular reason for using it, I'd reccomend that you use an
ANSI implementation.  I find it kind of annoying that GNU changed the
name, instead of calling it GNU AKCL, because people see the GNU mark
and think of up-to-date compilers like gcc.

If you're using it for the GNU mark, try GNU CLISP:
<http://clisp.cons.org/>

If you're using it for its ability to compile to native code, try CMUCL: 
<http://www.cons.org/cmucl/>

If you're using it because it compiles via the C compiler, try ECLS:
<http://ecls.sourceforge.net/>

If you're using it because it runs maxima, well, good choice :)
From: James A. Crippen
Subject: Re: Accessing Environment Variables
Date: 
Message-ID: <m37ku5mbls.fsf@kappa.unlambda.com>
···@conquest.OCF.Berkeley.EDU (Thomas F. Burdick) writes:

> If you're using it because it runs maxima, well, good choice :)

Not so.  Maxima was ported to CMUCL.  Not sure how up to date it is,
but the port was fairly recently I think.

'james

-- 
James A. Crippen <·····@unlambda.com> ,-./-.  Anchorage, Alaska,
Lambda Unlimited: Recursion 'R' Us   |  |/  | USA, 61.2069 N, 149.766 W,
Y = \f.(\x.f(xx)) (\x.f(xx))         |  |\  | Earth, Sol System,
Y(F) = F(Y(F))                        \_,-_/  Milky Way.
From: Kent M Pitman
Subject: Re: Accessing Environment Variables
Date: 
Message-ID: <sfwelodz5nb.fsf@world.std.com>
Cory Spencer <········@interchange.ubc.ca> writes:

> I'm somewhat new to Lisp (by somewhat, I mean entirely) and I've tried to
> no avail to find a method for accessing environment variables from within
> my Lisp programs, but haven't been able to.  (Environment variables being
> variables defined in the command line environment before I start up the
> Lisp interpreter.)  Anyone possibly point me in the right direction here?

Not all operating systems have such a thing.  It's not in the standard,
but vendors often provide a facility for you.

In LispWorks, for example, 
 (LISPWORKS:ENVIRONMENT-VARIABLE "PATH")
gets you the %PATH% variable on Windows or $PATH on Unix.

Using (APROPOS "ENV") will probably turn up some likely candidates
in most implementations if you can't find the documentation.