► |  | The Racket Reference

1 | Language Model
2 | Notation for Documentation
3 | Syntactic Forms
4 | Datatypes
5 | Structures
6 | Classes and Objects
7 | Units
8 | Contracts
9 | Pattern Matching
10 | Control Flow
11 | Concurrency and Parallelism
12 | Macros
13 | Input and Output
14 | Reflection and Security
15 | Operating System
16 | Memory Management
17 | Unsafe Operations
18 | Running Racket
| Bibliography
| Index

▼ | 10 | Control Flow

10.1 | Multiple Values
10.2 | Exceptions
10.3 | Delayed Evaluation
10.4 | Continuations
10.5 | Continuation Marks
10.6 | Breaks
10.7 | Exiting

On this page:

values
call-with-values

top ← prev up next →

#### 10.1`` Multiple Values

See Multiple Return Values for general information about multiple result values. In addition to call-with-values (described in this section), the let-values, let*-values, letrec-values, and define-values forms (among others) create continuations that receive multiple values.

> > procedure

> > (values v ...) → any

> v : any/c

Returns the given vs. That is, values returns its provided arguments.

Examples:

> > (values 1)
> 1
> > (values 1 2 3)

> 1
> 2
> 3

> > (values)

> > procedure

> > (call-with-values generator receiver) → any

> generator : (-> any)
> receiver : procedure?

Calls generator, and passes the values that generator produces as arguments to receiver. Thus, call-with-values creates a continuation that accepts any number of values that receiver can accept. The receiver procedure is called in tail position with respect to the call-with-values call.

Examples:

> > (call-with-values (lambda () (values 1 2)) +)
> 3
> > (call-with-values (lambda () 1) (lambda (x y) (+ x y)))
> #<procedure>: arity mismatch;
> the expected number of arguments does not match the given
> number
> expected: 2
> given: 1
> arguments...:
> 1

top ← prev up next →