Re: go "kill infinite loop"

2014-01-14 Thread Mark Mandel
On Wed, Jan 15, 2014 at 12:39 AM, Alex Miller wrote: > 2) Be careful using when using falsey tests like when or if - these will > stop on nil but will also stop on false coming through the channel. Might > be ok here, but it's something to be aware of. Oooh! that is a really good point! I hones

Re: go "kill infinite loop"

2014-01-14 Thread t x
@Alex: Noted. In practice, it's not much of a problem to me, since objects I'm sending over the channel are of the form: {:tag :message :return-chan ... :data ... actual message } On Tue, Jan 14, 2014 at 5:39 AM, Alex Miller wrote: > Two notes: > > 1)The provided core.async go-lo

Re: go "kill infinite loop"

2014-01-14 Thread Alex Miller
Two notes: 1)The provided core.async go-loop macro is a small enhancement for the (go (loop )) case. 2) Be careful using when using falsey tests like when or if - these will stop on nil but will also stop on false coming through the channel. Might be ok here, but it's something to be aware of.

Re: go "kill infinite loop"

2014-01-13 Thread t x
I really like Mark's while-let. I've always felt loop ... recur slightly cubersome, but never got around to writing a custom macro to just get around it. while-let much elegant. wow. On Mon, Jan 13, 2014 at 9:49 PM, Kelker Ryan wrote: > Maybe something like this? > > (go-loop [c (chan)] > (

Re: go "kill infinite loop"

2014-01-13 Thread Kelker Ryan
Maybe something like this? (go-loop [c (chan)] (let [x (: > On Mon Jan 13 18:11:10 2014, t x wrote: > >>  Consider the following code block: >> >>  (defn make-stupid [] >>    (go (loop [] >>  (recur >> >>  (def x (make-stupid)) >> >>  ;; ... is there a way to kill this infinite go-lo

Re: go "kill infinite loop"

2014-01-13 Thread Mark Mandel
I found this macro I wrote really useful for exactly this type of thing: https://github.com/markmandel/while-let As long as you are happy for your go loop to stop when nil comes through (i.e. when it gets closed). (go (while-let [data ( wrote: > Understood. Thanks for the clarification. > > > On

Re: go "kill infinite loop"

2014-01-13 Thread t x
Understood. Thanks for the clarification. On Mon, Jan 13, 2014 at 9:28 PM, Ben Mabey wrote: > On Mon Jan 13 18:11:10 2014, t x wrote: > >> Consider the following code block: >> >> >> (defn make-stupid [] >> (go (loop [] >> (recur >> >> (def x (make-stupid)) >> >> ;; ... is there a

Re: go "kill infinite loop"

2014-01-13 Thread Ben Mabey
On Mon Jan 13 18:11:10 2014, t x wrote: Consider the following code block: (defn make-stupid [] (go (loop [] (recur (def x (make-stupid)) ;; ... is there a way to kill this infinite go-loop ? No, you can not kill the loop with the go channel that is bound to x. You need to r