Opened 7 years ago

Closed 7 years ago

#87 closed defect (wontfix)

Allow multiple producers in `call-with-values`

Reported by: cowan Owned by: alexshinn
Priority: major Milestone:
Component: WG1 - Core Keywords:
Cc:

Description

In R5RS and R6RS, call-with-values takes two arguments, both procedures. The first is a producer of multiple values; the second is a consumer, to which the multiple values returned by producer are passed as arguments.

I propose allowing multiple producer arguments. This gives call-with-values the same power as Common Lisp multiple-value-call.

Change History (2)

comment:1 Changed 7 years ago by cowan

As an example, imagine an implementation of (physical) vectors, called vecs, using multiple values. To create a vec, we use make-vec, defined thus:

(define (make-vec x y z) (values x y z))

Then we can add vecs as follows:

(define (vec+ x1 y1 z1 x2 y2 z2)
  (make-vec (+ x1 y1) (+ x2 y2) (+ x3 y3)))

(define-syntax vecplus ()
  (syntax-rules
    ((vecplus a b) (call-with-values a b vec+))))

(vecplus (make-vec 1 2 3) (make-vec 4 5 6) => 5 7 9

Cross product, dot product, and so on can be implemented in the same style. In Scheme implementations where multiple values are put on the stack, this allows operations on vecs without boxing or unboxing them.

comment:2 Changed 7 years ago by cowan

  • Resolution set to wontfix
  • Status changed from new to closed

WG1 voted to reject multiple producers.

Note: See TracTickets for help on using tickets.