Next: , Previous: , Up: srfi environment-variables   [Index]


2.31.3 Rationale

Most operating systems provide a mechanism for passing auxiliary parameters implicitly to child processes. Usually, this mechanism is called “the environment”, and is conceptually a map from string names to string values. The string names are called environment variables.

Some applications rely on environment variables to modify their behavior according to local settings. Also, various established protocols rely on environment variables as a form of interprocess communication. For example, most implementations of the common gateway interface (CGI) use environment variables to pass Meta–Variables from the server to the script. Environment variables are also required by SRFI-96 SLIB Prerequisites. Providing a means to access environment variables is therefore indispensable for writing practical programs in Scheme.

Most widely–used Scheme implementations provide a function for getting the value of a specified environment variable. The name for this function is usually getenv, but varies (see below). Some implementations also provide a way to get all the environment variables, but others do not.

This SRFI specifies a uniform interface for accessing environment variables. That should make it easier to write portable programs that need access to their environment. For example, a CGI program may portably obtain the values of the Meta–Variables QUERY_STRING, CONTENT_LENGTH and REQUEST_METHOD as in the following examples:

(get-environment-variable "QUERY_STRING") => "foo=bar&huga=hige"
(get-environment-variable "CONTENT_LENGTH") => "512"
(get-environment-variable "REQUEST_METHOD") => "post"