[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Practical (values)

I think that you will find that a lot of Common Lisp implementations
handle one return value somewhat more efficiently than they handle zero
values.  There are two reasons for this: first, many implementations are
adaptations of older Lisp systems that had only single-value returns,
and the multiple value stuff was grafted on as an afterthought; second,
many newer implementations handle single-value return as a special case
that is carefully tuned for greatest performance, since the overwhelming
majority of Common Lisp calls (measured dynamically) either return only
a single value or immediately discard any additional values.  In some
implementations, returning NIL and returning (VALUES) may be equally
fast, but I don't know of any in which the latter form would be faster.

I suppose one could argue that returning (VALUES) is more perspicuous,
since it makes clear that the return value is of no interest.  But the
practice of returning NIL in such cases is a time-honored idom that is
unlikely to confuse anyone; a lot of people would have to stop and
consider what (VALUES) means.

-- Scott