<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Jul 11, 2013 at 4:42 PM, Matthias Felleisen <span dir="ltr"><<a href="mailto:matthias@ccs.neu.edu" target="_blank">matthias@ccs.neu.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Your uses of values are covered in apply/map/append/list trickeries.</blockquote><div><br></div>Yes, for example<br>(+ (values 1 2) (values 3 4))<br></div><div class="gmail_quote"><div>would need to be written<br></div><div>
(apply + (append (call-with-values (lambda()(values 1 2)) list) (call-with-values (lambda()(values 3 4)) list)))<br></div><div>which is really cumbersome.<br><br></div><div>However, actually, if `values' were exactly `list' (e.g., with `define-list' instead of `define-values'), I think it would be more usable than what it is now.<br>
</div><div>At least there would be no need to convert values to lists, use list operations, then convert lists back to values.<br></div><div>The above example would be written:<br></div><div>(apply + (append (list 1 2) (list 3 4)))<br>
</div><div>which is already much better.<br></div><div><br></div><div>But then, compared to splicing values, every call would need to be like this one, using `apply' and `append' everywhere, which is also quite cumbersome (and not elegant).<br>
</div><div>And `(list 1)' is not equivalent to `1'.<br></div><div><br></div><div>On the contrary, with splicing values, `(values 1)' is equivalent to `1', as it should be.<br></div><div><br></div>I guess Scribble would be happy to use such splicing values.<br>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Using values might be more elegant, but yes, it's currently not possible.<br></blockquote><div><br></div>
<div>And I think it's the kind of elegance that makes the distinction between usable and not.<br></div><div>(Since most languages are Turing-complete, features are not a matter of whether something can be done but of how much effort it takes to do something, but you are well aware of that, and Racket is very good at that, most of the time. I just wish some of the core designs would allow for a bit more flexibility.)<br>
<br>Laurent<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5"><br>
<br>
<br>
On Jul 11, 2013, at 8:56 AM, Laurent wrote:<br>
<br>
> 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.<br>
> In an extended Racket, this would look like this:<br>
><br>
> (+ (values 1 2) (values 3 4))<br>
> would be equivalent to<br>
> (+ 1 2 3 4)<br>
><br>
> (map values '(0 1 2) '(a b c))<br>
> would return<br>
> '(0 a 1 b 2 c)<br>
><br>
> (call-with-values (lambda()(my-proc ....)) list)<br>
> would simply be<br>
> (list (my-proc ....))<br>
><br>
> (values (values 1 2) (values 'a 'b))<br>
> would be equivalent to<br>
> (values 1 2 'a 'b)<br>
><br>
> 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.<br>
><br>
> 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.<br>
><br>
> 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.<br>
><br>
> Do you see some disadvantages of using values this way?<br>
> For example, in some occasions, for things like<br>
> (define (foo x) (values x x))<br>
> (map + (foo '(1 2 3)))<br>
> 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.<br>
><br>
> Laurent<br>
</div></div>> ____________________<br>
> Racket Users list:<br>
> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br>
</blockquote></div><br></div></div>