Printing
There is no invisible
in Lisp, so whatever your function returns will be printed by the the P
(print) part of the REPL. This means that if your print settings are inappropriate, the system may print many screenfuls (you may even get a confusing stack overflow error because your print-circle is nil
and the return value is a circular structure).
Compilation
The compiler can do some optimizations (which a specific compiler may or may not actually do in practice); e.g., it may mark the function as not returning anything interesting and then compile expressions like (setq var (my-func))
to (progn (my-func) (setq var nil))
.
If the compiler can prove that the function has no side effects and you end it with (values)
then the compiler can just drop its invocations altogether.
Documentation
An important aspect of computer programming is that your code will be read by other humans, including yourself, and adding (values)
to the end of the function tells the reader that the function is called for side effects only.