Every habitat has certain conditions which make it suitable for some organisms but not for others. These conditions make up the environment. An organism's environment consists of two parts: the physical (abiotic) environment and the biological (biotic) environment.

The physical environment includes physical features such as temperature, light, etc. The biotic environment is made up of all the other organisms in the habitat.

In computer science, an environment is a function from a finite set of symbols to the set of all values. In other words, it is a way of matching variables to their values. Environments are indispensable in the implementation of programming languages.

Compare substitution.
An environment in computer science consists of the following quintupel E = {X,Y,Z,d,l}.
X - the finite set of actions
Y - the finite set of looks
Z - the not necessary finite set of the points of the environment
d - is a partial function, d(P,x) where P ∈ Z and x ∈ X returns a new point P´
l - is a function l(P), which returns the look ∈ Y of the current point.

the P ∈ Z is normally not given, as it is the current point.
A punctured (I do not know if this is the right word) environment consists of the environment itself plus the start point O ∈ Z.

There are several different environments in computer science, such as Turing,RAM and Stack environment. All three are to complicated to be used as examples, I will write something about them later, and will hard link them.
The example environment is useful,too. It is the counting environment:
Z= N (set of all natural numbers)
l(0) = 0 otherwise l(n) = 1
d(0,-1) = not defined, otherwise d(n,x) = n+x
All this environment can do is count. The actions are: adding +1, -1 or 0. The 0 is needed if one works with more than one counting environment and wants to add something to one of them and let the other one unchanged.
The most interesting thing is that Y (the set of the looks) is not N but only consists of 2 elements. The reason for this is, that Y may not be infinite. The look is 1 if the point (here a member of N) is not equal to 0. If you want to find the value of a point, you have to do d(n,-1) till the look is = 0 and store the number of actions you did (and you should not forget to count back to the number, because otherwise the number is lost afterwards).

Some additional facts:

  • Every set of actions X contains at least one action "stop" (equivalent to 0 in the counting environment): d(P,stop) = P
  • The valence of a given point is the set of actions executable from this point: val(P) = {x ∈ X | d(P,x) &neq; n.d.} Example: val(0) = {0,+1), val(1) = (0,+1,-1)

In many operating systems, such as UNIX (and its free incarnation Linux), as well as MS-DOS and Windows, " environment" refers to a set of variables, always taking string values, that can be read or written to by a program, but are inherited by all processes the program may spawn. Think of it as a little piece of the shell that every program carries with itself.

Environment variables are best suited for values that are used once at the beginning of a program, and are ALWAYS set to one value or another. That is, a variable that is *so* frequently used that it becomes noise on a command line should be an environment variable.

Although every program has the potential to access its own environment, and make changes that will be reflected in any processes it spawns, the program best suited to setting environment variables is the operating system's shell. Each shell has its own syntax for setting them.


Bourne Shell:
export value

C Shell:
export varname=value

Any *n?x shell, for the execution of one program:
varname=value program-name program-arguments...

Programs written in high-level languages (such as C) for an operating system that uses environments usually include functions for retrieving and setting environment variables. To this end, the C Standard Library contains a getenv function and a setenv function. Also, a C program's main() function can be declared with a third formal parameter, viz.

int main (int argc, char *argv[], char **envp)

When the program is run, the shell (actually one flavor of exec()) passes a copy of the current environment into main. Each string in the list is of the form varname=value.

Many scripting languages, such as awk or Perl, have their own ways of accessing the envorionment. Every awk script has an associative array named ENVIRON. Thus, the expression


will return the indicated variable's value, and


will set a new value.

En*vi"ron*ment (?), n. [Cf. F. environnement.]


Act of environing; state of being environed.


That which environs or surrounds; surrounding conditions, influences, or forces, by which living forms are influenced and modified in their growth and development.

It is no friendly environment, this of thine. Carlyle.


© Webster 1913.

Log in or register to write something here or to contact authors.