On Aug 23, 3:53 pm, Allen Rohner <[EMAIL PROTECTED]> wrote:
> I had a small amount of confusion about the "appearance" or
> "structure" of let, for, and doseq.
>
> We're all familiar with (let), to create local variables
>
> (let [varA (foo)
>        varB (bar)]
>     (+ varA varB))
>
> (for) does something similar, binding a local variable to each item in
> a list in turn.
>
> (for [varA my_seq]
>     (my_fun varA))
>
> I wrote some code, thinking I wanted a for loop. But since I wanted
> side effects, I should have used doseq. doseq however, doesn't look
> like let and for:
>
> (doseq varA my_seq
>     (my_fun varA))
>
> IMO, (let) and (for) are significantly more readable than doseq.
> Because (for) shares the same structural appearance as (let), it gives
> a hint to the user that for is binding variables. I know this is a
> small point, but having consistency on the functions that create local
> variables would be useful, IMO.
>
> I guess I'm suggesting that doseq be modified to take an array of
> variables and lists, so it appears similar to let and for.
>
> i.e (doseq [varA my_seq]
>         (my_fun varA))
>

I agree, and in retrospect think that all macros that take binding
lists should take them in vectors.

Unfortunately, this would be a breaking change, as

(doseq [k v] amap
  (do-something-with k v))

is valid code that uses destructuring, whose interpretation would
change.

Rich

--~--~---------~--~----~------------~-------~--~----~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to