On Thu, Dec 10, 2009 at 9:15 AM, ngocdaothanh <ngocdaoth...@gmail.com> wrote:
> Hi,
>
> I want to ask about code arrangement and understandability
> (readability).
>
> Consider this "normal" code:
> x = 1
> ...
> f(x)
> ...
> y = x + 2
> ...
> g(y)
>
> x, f, y, g have the same "abstractness" level, so they are indented to
> the same level.

In what sense do they have the 'same abstractness level'? What do you
mean by abstractness? g(y) depends upon y; y depends upon x; nothing
depends upon f(x), so presumably it is being called for side effects.
I don't see anything similar about them.

You could also write

(let [x 1
      _ (f x)
      y (+ x 2)
      _ (g y)]
  ...)

which puts them all at the same nesting level.

Best,
Graham

>
> My Clojure code:
> (let [x 1]
>  ...
>  (f x)
>  ...
>  (let [y (+ x 2)]
>    ...
>    (g y)))
>
> It is very difficult to capture the "algorithm" behind the Clojure
> code because things of the same "abstractness" level do not have the
> same indent level.
>
> How to rearrange the Clojure code for understandability?
>
> I have been studying Clojure for several months now but I could never
> "get" it. But I couldn't explain why I couldn't get it, I just didn't
> know why. But today I think I have found the reason: I think the
> problem of Clojure (and Lisp) is not parenthesis, its problem is
> indent.
>
> I think if I can "let over" this problem, I will be enlightened. Would
> you please help me?
>
> Thank you,
> Ngoc
>
> --
> 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 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