Re: recur does not work within some macros, how to deal with it?

2015-12-18 Thread Witold Szczerba
You are so right, the answer seems obvious now :) Thanks, Witold Szczerba On Sat, Dec 19, 2015 at 1:57 AM, Herwig Hochleitner wrote: > Use a function instead of the loop: > > (defn ws [req] > (with-channel req channel > ((fn loop-f [x] >

recur does not work within some macros, how to deal with it?

2015-12-18 Thread Witold Szczerba
Hi, I am doing my first steps in Clojure and I have a problem with "recur". Here's an example of the HTTP Kit's handler I just wrote to test drive the first Clojure piece of code of mine: (defn ws [req] (with-channel req channel (loop [x 1] (timer/schedule-task 3000

Re: recur does not work within some macros, how to deal with it?

2015-12-18 Thread Herwig Hochleitner
Use a function instead of the loop: (defn ws [req] (with-channel req channel ((fn loop-f [x] (timer/schedule-task 3000 (println x) (loop-f (+ x 1 0))) loop-recur is used to prevent unbounded stack growth, but the timer task acts as a sort of