What’s the difference between using (values …)
versus (list …)
(or literally '(one two three …)
) to return multiple values from a lambda
(or other implicit progn
)? Does it create some special glue to multiple-value-bind
? Superficially, I can’t see any difference and am curious whether it’s merely a convention for multiple return values.
2
This question has been already answered on SO: values function in Common Lisp.
Briefly, multiple values is a facility to return many objects without allocating extra memory.
E.g. floor
must return two values – quotient and remainder.
It can return a list
(or a pair) or it can return two values.
In the former case it will have to allocate a cons cell on each call, in
the second it will not.
This means that multiple values have certain limitations
(one cannot return more than 20 values portably).
2