▼ |  | Unstable: May Change Without Warning

1 | Guidelines for Developing unstable Libraries
2 | Automata: Compiling State Machines
3 | Bytes
4 | Contracts
5 | Converting Values to Strings
6 | Contracts for Macro Subexpressions
7 | Debugging
8 | Definitions
9 | Filesystem
10 | Find
11 | Flonums
12 | Futures
13 | Functions
14 | Hash Tables
15 | Interface-Oriented Programming for Classes
16 | Lazy Require
17 | Lists
18 | Logging
19 | Mark Parameters
20 | Match
21 | Parameter Groups
22 | Pretty-Printing
23 | Sequences
24 | Strings
25 | Structs
26 | Syntax
27 | Temporal Contracts: Explicit Contract Monitors
28 | GUI Libraries

On this page:

parameter-group?
define-parameter-group
parameterize/ group
parameterize*/ group

Version: 5.3
top← prev up next →

### 21`` Parameter Groups

Neil Toronto <ntoronto@racket-lang.org>

This library is unstable; compatibility will not be maintained. See Unstable: May Change Without Warning for more information.

(require unstable/parameter-group)

Parameter groups are parameter-like views that represent multiple parameters.

Examples:

> > (require unstable/parameter-group)

> > (define param1 (make-parameter 1))

> > (define param2 (make-parameter 2))

> > (define-parameter-group params (param1 param2))

> > (params)
> (params-value 1 2)

> > (parameterize/group ([params (params-value 10 20)])
> (list (param1) (param2)))

> '(10 20)
> > (params)
> (params-value 1 2)
> > (params (params-value 100 200))

> > (list (param1) (param2))
> '(100 200)

Use parameter groups to conveniently set multiple parameters. For example, the plot library uses parameter groups to save and restore appearance-controlling parameters when it must draw plots within a thunk.

> > procedure

> > (parameter-group? v) → boolean?

> v : any/c

Returns #t when v is a parameter group.

> > syntax

> > (define-parameter-group name (param-or-group-expr ...) options)

> options

> =

> |  | | |  | #:struct struct-name

> | param-or-group-expr |  | : |  | (or/c parameter? parameter-group?)

Defines a new parameter group.

If struct-name is not given, define-parameter-group defines a new struct <name>-value to hold the values of parameters.

If struct-name is given, it must have a constructor (struct-name param-or-group-expr ...) that accepts as many arguments as there are parameters in the group, and a struct-name match expander that accepts as many patterns as there are parameters.

Examples:

> > (struct two-params (p1 p2) #:transparent)

> > (define-parameter-group params* (param1 param2) #:struct two-params)

> > (params*)
> (two-params 100 200)

> > syntax

> > (parameterize/group ([param-or-group-expr value-expr] ...)
> > body-expr ...+)

> | param-or-group-expr |  | : |  | (or/c parameter? parameter-group?)

Corresponds to parameterize, but can parameterize parameter groups as well as parameters.

> > syntax

> > (parameterize*/group ([param-or-group-expr value-expr] ...)
> > body-expr ...+)

> | param-or-group-expr |  | : |  | (or/c parameter? parameter-group?)

Corresponds to parameterize*, but can parameterize parameter groups as well as parameters.
top← prev up next →