[plt-scheme] How do I convert (values ...) to something I can do something with?

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Wed Mar 10 13:29:06 EST 2010

Ask and you receive.

I also implemented rest-values and optional values because it was easy to do.

(let-values+ ([x 10]
               [(y) 2])
              (list x y))
 =>
 (list (list 10) 2)

 (let-values+ ([(x [z 3]) 11]
               [(y) 2])
              (list x y z))
 =>
 (list 11 2 3)

 (let-values+ ([(x #:foo z) (values+ 12 #:foo 3)]
               [(y) 2])
              (list x y z))
 =>
 (list 12 2 3)

Jay

On Wed, Mar 10, 2010 at 8:28 AM,  <hendrik at topoi.pooq.com> wrote:
> On Tue, Mar 09, 2010 at 10:27:03PM -0700, Jay McCarthy wrote:
>> I use multiple value returns _a lot_.
>>
>> I try to never overload lists or pairs and instead always make
>> structs. I try to limit myself to structs that "make sense" in the
>> wild as opposed to ones that will only be produced/consumed by a
>> single function; I find that in those cases I really want multiple
>> values.
>>
>> However, multiple values have a problem that when you get more than a
>> few it is complicated to remember which is which because all you have
>> is positions. At least with function calls you can have keyword args.
>> In those cases, I let myself use a struct, but I feel bad about it.
>
> Arguments and results are category-theoretical duals.  If you have
> multiple arguments, you should have multiple results.  If you have
> keyword arguments, you should have keyword results.  Get with it,
> language designers!
>
> -- hendrik  :-)
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://teammccarthy.org/jay

"The glory of God is Intelligence" - D&C 93
-------------- next part --------------
A non-text attachment was scrubbed...
Name: values.ss
Type: application/octet-stream
Size: 4862 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20100310/1f791e46/attachment.obj>

Posted on the users mailing list.