[plt-scheme] Performance of (values x y z) vs (list x y z)?
Hi there,
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
Is there any particular virtue in one form over the other?
Might this relate to the topic on closures vs structs vs tuples
that we had the other day? How does it relate to apply?
Are any of the answers that apply in the case of mzscheme
particularly different if the question is asked of other
contemporary implementations?
To my surprise, when I tried a few doodles to test these
questions, the first version appeared to have a bit of a
performance edge: I'd expected the latter to be faster. I'm new
enough at this game to accept that my tests could have been
swamped by other factors...
Cheers,
--
Andrew