[racket] Splicing `values' in-place
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130711/a9adb746/attachment.html>