The big advantage to my reorganization of your loop is that it doesn't have
an unused "x" binding.

The other advantage is that the expressions bound to "x" and "y" are not
repeated at the beginning of the loop and at the end.

Also, (and this is less clear cut, more opinion), it's typical for a loop
binding to be something that depends on the previous iteration of the loop,
e.g.:

(loop [x 10] (when (> x 0) (recur (dec x)))

In this example, the value of "x" always depends on the previous loop
iteration.  Contrast that with:

(loop [x (read-line)] (do (println "Hello " x) (recur (read-line)))

In this example, the value of "x" is arbitrary, and doesn't really have
anything to do with the previous loop iteration.  And thus, IMHO, it
shouldn't be a loop binding.


On Tue, Feb 12, 2013 at 8:06 AM, George Oliver <georgeolive...@gmail.com>wrote:

> @Baishampayan, I'm just experimenting at the repl right now so there's no
> stopping condition yet. It's a socket server.
>
>
> On Monday, February 11, 2013 11:56:22 PM UTC-8, Evan Mezeske wrote:
>>
>> Generally when you are calling functions that have (and depend on)
>> side-effects, you will end up using "do" a lot.  Also, I noticed that in
>> your example there's really no reason to make the x and y bindings part of
>> the loop.
>>
>
> I hadn't thought about using a let in the loop but you're right, I could
> just as easily bind in a let. Is there a benefit to doing it there rather
> than in the loop binding? Maybe it makes it easier to read?
>
> --
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to