[plt-scheme] Performance of (values x y z) vs (list x y z)?

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Wed Jun 6 10:18:56 EDT 2007

The error checking involved with values (arity, closures underneat  
let-values) could dominate the error checking for lists (car, cdr).  
See Dybvig's PLDI paper. -- Matthias


On Jun 6, 2007, at 4:45 AM, Matthew Flatt wrote:

> At Wed, 6 Jun 2007 18:04:00 +1000, Andrew Reilly wrote:
>> Is there an expectation of a performance difference between,
>> say:
>>
>> (define (foo)
>>   (list 1 2 3))
>>
>> (define (use-foo)
>>  (let ((f (foo)))
>>   (let ((a (car f)) (b (cadr f)) (c (caddr f)))
>>    (baz a b c))))  ; let's pretend that baz is something
>>    ; complicated, in-line here, so (apply baz f) doesn't count,
>>    ; although I suspect that that's related to the next part...
>>
>> vs:
>>
>> (define (foo)
>>  (values 1 2 3))
>>
>> (define (use-foo)
>>  (let-values (((a b c) (foo)))
>>   (baz a b c))) ; same constraint of non-triviality in a, b, c
>>   ; as above
>>
>> [...] I'd expected the latter to be faster.
>
> Me, too, mostly because `values' will tend not to allocate.
>
> Matthew
>
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.