kibit icon indicating copy to clipboard operation
kibit copied to clipboard

Bad advice on (loop [] (when ... (recur)))

Open eigenhombre opened this issue 10 years ago • 1 comments
trafficstars

The following code

(loop []
  (when (> 2 1)
    (println "Continuing...")
    (Thread/sleep 300)
    (recur)))

generates the following Kibit warning:

At /Users/jjacobsen/.../breakkibit/src/breakkibit/core.clj:4:
Consider using:
  (while (> 2 1) (println "Continuing...") (Thread/sleep 300) (recur))
instead of:
  (loop []
    (when (> 2 1) (println "Continuing...") (Thread/sleep 300) (recur)))

The proposed (recur) isn't needed and in fact won't compile.

eigenhombre avatar Jul 06 '15 15:07 eigenhombre

Thanks for reporting this, I'll take a look ASAP. Thanks!

danielcompton avatar Jul 07 '15 04:07 danielcompton