Hello,

don't let anybody convince you that clojure code should be both
compact and unreadable for common mortals to deserve the right to be
called idiomatic !

The first example which you consider "clojure style" is unredeable !

I tried several variations of coding this in clojure (not tested)

here: http://pastebin.com/4G5DN3Jw

IMO, Idiomatic clojure code is more in corerctly using the different
parts: correct separation of state and identity, right balance between
functions / multimethods / macros / (coming in 1.2) protocols, prefer
higher order functions if they do not impact on readability and/or
performance, etc.

HTH,

-- 
Laurent

2010/5/19 edlich <edl...@gmail.com>:
> Dear Community,
>
> I have one question about readability. As I am not yet deep into
> Clojure I can only post scala but I am sure you will get my point.
>
> Recently I wrote the following dump function in Scala:
>
>  // convert 1228 to "e2e4"
>  def move2ascii(move: Int): String = { // Clojure Style
>    (((move / 100) % 8 + 97).toChar).toString + ((move / 100) / 8 +
> 1).toString +
>            (((move % 100) % 8 + 97).toChar).toString + ((move %
> 100) / 8 + 1).toString
>  }
>
> but I could as well have written it like this in an imprative style:
> (both are equal)
>
> def move2ascii(move: Int): String = {    // Scala Style
>    val f1 = move / 100
>    val f2 = move % 100
>    val row1 = f1 / 8 + 1 // 2 von e2
>    val row2 = f2 / 8 + 1 // 4 von e4
>    val col1 = (f1 % 8 + 97).toChar // 5 = e von e2
>    val col2 = (f2 % 8 + 97).toChar // 5 = e von e4
>    col1.toString + row1.toString + col2.toString + row2.toString
>  }
>
> I am sure if you write the first function in Clojure it would look
> nearly the same.
>
> My point and my question is:
>
> Isn't the second function easier to read? I know there had been a lot
> of threads about readability
> in clojure but I am not yet convinced.
> In the second version the brain can rely on some steps inbetween which
> make it more readable
> for me. Or should the first function be split up into several more
> functions to become more readable?
>
> I would be happy if you convince me to give Clojure a better chance.
>
> Thanks in advance
> Stefan Edlich
>
> P.S.: It's nice to see the upcoming Clojure book in Manning!
>
> --
> 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