1 Evaluation Model
2 Syntax Model
3 Core Syntactic Forms
4 Core Datatypes
5 Structures
6 Classes and Objects
7 Units
8 Contracts
9 Control Flow
10 Concurrency
11 Macros
12 Input and Output
13 Reflection and Security
14 Operating System
15 Memory Management
16 Running PLT Scheme
Index
On this page:
values
call-with-values

contents

 index

← prev  up  next →

 

9.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.

(values v ...)  any

  v : any/c

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

Examples:

  > (values 1)

  1

  > (values 1 2 3)

  1

  2

  3

  > (values)

(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)))

  context (lexical binding) expected 2 values, received 1

  value: 1

 

contents

 index

← prev  up  next →