▼ |  | Unstable: May Change Without Warning

1 | Guidelines for Developing unstable Libraries
2 | Automata: Compiling State Machines
3 | Bytes
4 | Contracts
5 | Contracts for Macro Subexpressions
6 | Debugging
7 | Definitions
8 | Errors
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 | Macro Testing
20 | Mark Parameters
21 | Match
22 | Open place expressions
23 | Options
24 | Parameter Groups
25 | Pretty-Printing
26 | Re-Contracting Identifiers
27 | Sandbox
28 | Sequences
29 | Strings
30 | Structs
31 | Struct Printing
32 | Syntax
33 | Temporal Contracts: Explicit Contract Monitors
34 | Unix Domain Sockets
35 | 2D Syntax
36 | GUI Libraries

On this page:

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

5.3.6
top ← prev up next →

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