Next: , Previous: , Up: Miscellaneous Datatypes   [Contents][Index]

10.3 Parameters

Parameters are objects that can be bound to new values for the duration of a dynamic extent. See Dynamic Binding.

procedure: make-parameter init [converter]
procedure: make-unsettable-parameter init [converter]

Returns a newly allocated parameter object, which is a procedure that accepts zero arguments and returns the value associated with the parameter object. Initially this value is the value of (converter init), or of init if the conversion procedure converter is not specified. The associated value can be temporarily changed using the parameterize special form (see parameterize).

The make-parameter procedure is standardized by SRFI 39 and by R7RS, while make-unsettable-parameter is an MIT/GNU Scheme extension.

procedure: make-settable-parameter init [converter]

This procedure is like make-parameter, except that the returned parameter object may also be assigned by passing it an argument. Note that an assignment to a settable parameter affects only the extent of its current binding.

make-settable-parameter is an MIT/GNU Scheme extension.

procedure: parameterize* bindings thunk

Bindings should be an alist associating parameter objects with new values. Returns the value of thunk while the parameters are dynamically bound to the values.

Note that the parameterize special form expands into a call to this procedure. parameterize* is an MIT/GNU Scheme extension.

10.3.1 Cells

A cell object is very similar to a parameter but is not implemented in multi-processing worlds and thus is deprecated. Parameters should be used instead.

procedure: cell? object

Returns #t if object is a cell; otherwise returns #f.

procedure: make-cell object

Returns a newly allocated cell whose contents is object.

procedure: cell-contents cell

Returns the current contents of cell.

procedure: set-cell-contents! cell object

Alters the contents of cell to be object. Returns an unspecified value.

procedure: bind-cell-contents! cell object thunk

Alters the contents of cell to be object, calls thunk with no arguments, then restores the original contents of cell and returns the value returned by thunk. This is completely equivalent to dynamic binding of a variable, including the behavior when continuations are used (see Dynamic Binding).

Next: Records, Previous: Symbols, Up: Miscellaneous Datatypes   [Contents][Index]