▼ |  | 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 | Errors
10 | Filesystem
11 | Find
12 | Flonums
13 | Futures
14 | Functions
15 | Hash Tables
16 | Interface-Oriented Programming for Classes
17 | Lazy Require
18 | Lists
19 | Logging
20 | Mark Parameters
21 | Match
22 | Open place expressions
23 | Parameter Groups
24 | Pretty-Printing
25 | Re-Contracting Identifiers
26 | Sandbox
27 | Sequences
28 | Strings
29 | Structs
30 | Struct Printing
31 | Syntax
32 | Temporal Contracts: Explicit Contract Monitors
33 | GUI Libraries

On this page:

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

Version: 5.3.1
top ← prev up next →

### 23`` 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 →