Windows and POSIX systems support the use of 'EnvironmentVariables', which are essentially string->string associative arrays. While these generally serve purpose in identifying 'homes' for things and lookup paths for dynamic libraries and such, they also offer an alternative vector for process and script parameters. For example, a whole panoply of EnvironmentVariables form the parameters for CGI, and 'CFLAGS' is a well known environment variable parameter to gcc.
The primary advantages over 'explicit' parameters (e.g. command-line options) are:
- it is implicitly forwarded into each process. This both means less typing and less need to modify scripts and such to explicitly deliver correct options to the processes they spawn.
- it is easy to set up an initial environment with parameters common to different processes and applications.
The primary advantage of this form of parameter over registry settings and configuration files is:
- environments are essentially concurrent by way of being copied for each process, whereas registry settings and configuration files are global to all instances of a process. If a computer is likely to be running multiple instances of a process each with variations in parameters, it is much better that parameters be passed to it either via the environment or explicitly.
The disadvantage is that it is one more thing you need to get right before your processes will work.
A nice way to handle this is ExplicitManagementOfImplicitContext.
See also ThreadLocalVariable