[plt-scheme] keyword return values

From: Doug Orleans (dougorleans at gmail.com)
Date: Wed May 6 15:31:09 EDT 2009

Scheme has a nice symmetry between arguments and return values.
Procedures like make-do-sequence take advantage of this: instead of
taking six arguments, it takes a thunk that returns six values, so
that it can generate the six values fresh every time an iterator is
created.  I'm always forgetting the order of the values, though; if
they were arguments, then make-do-sequence could use keyword arguments
so you wouldn't have to remember the order.  But return values can't
include keywords:

> (call-with-values (lambda () (values #:y 3 1)) (lambda (x #:y (y 2)) (list x y)))
procedure application: expected a procedure that accepts keyword
arguments, given #<procedure:values>; arguments were: 1 #:y 3

Would it be feasible to allow this?  I think that would restore the
symmetry between arguments and return values.

--dougorleans at gmail.com


Posted on the users mailing list.