Can someone please explain why Clojure's while macro doesn't return a value?

The documentation says "Presumes some side-effect will cause test to become false/nil." Okay, so we use swap! to modify the atom which is used in the test case. But can't we still have a return value (perhaps returning repeatedly, as in the case with loop ), along with the side effects?

Looking at the source, it seems like the cause could be something to do with how recursion and macros work, but I don't know enough about the internals of that to speculate.

Example:

The following code only returns nil :

(let [a (atom 0)] (while (< @a 10) (+ 1 @a) (swap! a inc)))

That is, it does not return the value of (+ 1 @a) , nor does it return any other value or function that is inside the while loop. If we want to get some value calculated via the while loop, we could use print , but then we can't easily use the value in some other operation. For a return value, we have to use a second atom, like this: