As a relative Clojure novice I'm finding Lisp's s-expressions provide a simplified debugging experience, Java stacktraces aside, unparallelled in any other language I've come across. I was recently having trouble with this function:

(defn shared-aspects [my-id your-id]
  (for [[{left :l right :r id1 :id asp1 :aspect} {asp2 :aspect}]
         (partition 2 (sql-aspects-by-id {:mi my-id :yi your-id}))
        :let [asp1 (keyword asp1)
              asp2 (keyword asp2)
              rg (if (= id1 my-id) (str (asp->colour asp1)
                                        (asp->colour asp2))
                                        (str (asp->colour asp2)
                                             (asp->colour asp1)))]]
{:rg rg :asp-id ((first (sql-joint-aspect-id {:le left :ri right :ty "shared"})) :id)}))


The magic of s-expressions allowed me to extract what I suspected was the culprit:

(partition 2 (sql-aspects-by-id {:mi my-id :yi your-id}))

... and test it separately in the REPL. I was able to first test the function's output, assess it's suitability for the end result I required then, when found unsatisfactory, substitute various alternatives to partition and slot the modified version back into the main function defintion. This option of wrapping and substituting is what makes Lisp so special within a live REPL.

Other functional languages, such as Scala and Haskell, claim to enjoy a similar level of composability but I can't imagine anything without s-expressions offering quite the same experience.

gvim

--
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/d/optout.

Reply via email to