[previous] [up] [next]     [contents] [index]
Next: Parameterization Utilities Up: Parameterizations Previous: Random Numbers

Parameter Utilities

(make-parameter v [guard]) returns a new parameter procedure. The value of the parameter is initialized to v in all parameterizations. If guard is supplied, it is used as the parameter's guard procedure. A guard procedure takes one argument. Whenever the parameter procedure is applied to an argument, the argument is passed on to the guard procedure. The result returned by the guard procedure is used as the new parameter value. A guard procedure can raise an exception to reject a change to the parameter's value.

(parameter? v) returns #t if v is a parameter procedure, #f otherwise.

(parameter-procedure=? a b) returns #t if the parameter procedures a and b always modify the same parameter, #f otherwise.

The parameterize syntactic form temporarily sets the value of a parameter while evaluating a body expression, and then restores the parameter value before returning the result of the body. The syntax of parameterize is:

  (parameterize ((parameter value)  tex2html_wrap_inline12550 ) body-expr  tex2html_wrap_inline12552 ) 
The result of a parameterize expression is the result of the last body-expr. During the evaluation of the body-exprs, each parameter is set in the current parameterization to the corresponding value. Once the body-exprs are evaluated, each parameter is restored to its value from before evaluating the parameterize expression. If any body-expr changes the current parameterization, the parameter values are nevertheless restored in the parameterization that was current before the evaluating the parameterize expression.



PLT