[previous] [up] [next]     [contents] [index]
Next: Built-in Parameters Up: Threads and Namespaces Previous: Keywords

Parameterizations

A parameter is a procedure that stores and retrieves the state of some value. For example, the current-output-port parameter stores a port value that is used by display when a specific output port is not provided. The current value of a parameter is obtained by applying the parameter procedure to zero arguments. The value of a parameter is set by applying the parameter procedure to a value. (The result of a parameter-setting application is void.) For example, (current-output-port) returns the current default output port, while (current-output-port p) sets the default output port to p.

The use of parameters is complicated by the use of threads. For some parameters, such as current-exception-handler, each thread usually needs its own value; for other parameters, such as current-output-port, multiple threads often need to share the parameter value. In general, the way in which parameters are shared across threads is application-dependent. For this reason, a parameterization -- a collection of parameter values -- is a first-class value, and a parameterization is explicitly associated with each thread. Two parameterizations can share the state of a particular parameter, so that when the parameter value is changed in either parameterization, both parameterizations see the change.

When a parameter procedure is invoked directly, the parameter value is set or returned from the current thread's current parameterization. The in-parameterization procedure (see section 9.4.3) takes a parameterization and a parameter, returning a new procedure that gets or sets the parameter value in the specified parameterization.





PLT