[racket] Splicing `values' in-place

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Thu Jul 11 10:42:52 EDT 2013

Your uses of values are covered in apply/map/append/list trickeries. Using values might be more elegant, but yes, it's currently not possible. 



On Jul 11, 2013, at 8:56 AM, Laurent wrote:

> In some postfix languages, if a procedure returns multiple values, these values can be used directly as multiple arguments to another procedure call, i.e., they are "spliced" in the latter call.
> In an extended Racket, this would look like this:
> 
> (+ (values 1 2) (values 3 4)) 
> would be equivalent to 
> (+ 1 2 3 4)
> 
> (map values '(0 1 2) '(a b c))
> would return
> '(0 a 1 b 2 c)
> 
> (call-with-values (lambda()(my-proc ....)) list)
> would simply be 
> (list (my-proc ....))
> 
> (values (values 1 2) (values 'a 'b))
> would be equivalent to 
> (values 1 2 'a 'b)
> 
> Correct me if I'm wrong, but I think all the cases where this feature should be useful currently throws an error, so it would probably break only very little.
> 
> Such a missing feature tickles me from time to time, and I often find that Racket `values' system is too cumbersome to be used more often, i.e., you need to go through stages of `call-with-values', 'let/define-values', `(apply values ....)', etc. and I often find myself not wanting to go down this road.
> 
> IMO, `values' is *meant* to be the way I describe above: `values' is exactly like `list', except than instead of encapsulating the values in a container, it splices them in-place.
> 
> Do you see some disadvantages of using values this way?
> For example, in some occasions, for things like
> (define (foo x) (values x x))
> (map + (foo '(1 2 3)))
> it may be more difficult to infer that there are actually 2 lists in the map, but to me it's just a matter of style/taste/comments/documentation, not a matter of feature.
> 
> Laurent
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4373 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20130711/a5dbab66/attachment-0001.p7s>

Posted on the users mailing list.