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

On this page:

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

5.92
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)
| package: unstable-parameter-group-lib

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 →