Benny Tsai <benny.t...@gmail.com> writes:

> There's "while" in clojure.core; would that work?

That would be cheating:

--8<---------------cut here---------------start------------->8---
user> (macroexpand '(while (foo) (bar)))
(loop* [] (clojure.core/when (foo) (bar) (recur)))
--8<---------------cut here---------------end--------------->8---

And of course, `when` expands to an `if` again.

> On Tuesday, May 29, 2012 8:13:24 AM UTC-7, Andrew wrote:
>>
>> Thanks for sharing your blog post. Is there an Anti-If alternative to
>> loop/recur in a situation where you have to poll for a condition to
>> be true? (Seems to me that this necessitates some kind of conditional
>> statement)

If the value checked by the predicate is held in some clojure reference
type, you can add a watch function (`add-watch`).  You still need to
test the predicate in the watch function, but at least you don't need to
do polling, because the watch function will only be called when the
value changes.

Bye,
Tassilo

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to