>From my perspective, having the forms be flatter (less nested) and
having the call to the extend-dom function be at the outermost level
is the most readable.

On Fri, Oct 23, 2009 at 1:20 PM, Meikel Brandmeyer <m...@kotka.de> wrote:
> Hi,
>
> Am 23.10.2009 um 21:16 schrieb Howard Lewis Ship:
>
>> Here's what I wanted to write:
>>
>> (defn add-script-links-for-imported-javascript-libraries
>>       [env dom-nodes]
>>       (extend-dom dom-nodes [:html :head] :top
>>               (template-for [:let [aggregation (-> env :cascade :resource-
>> aggregation)
>>                                         libraries (@aggregation :libraries)]
>>                                   asset-map libraries
>>                                   :let [path (to-asset-path env asset-map)]]
>>                       :script { :type "text/javascript" :src path } [ 
>> linebreak ])))
>
> Why don't you just go one step further?
>
> (defn add-script-links-for-imported-javascript-libraries
>   [env dom-nodes]
>   (extend-dom dom-nodes [:html :head] :top
>     (template-for [asset-map (-> env
>                                :cascade
>                                :resource-aggregation
>                                deref
>                                :libraries)
>                    :let [path (to-asset-path env asset-map)]]
>       :script { :type "text/javascript" :src path } [ linebreak ])))
>
>> But I had to juggle it to this:
>>
>> (defn add-script-links-for-imported-javascript-libraries
>>       [env dom-nodes]
>>       (let [aggregation (-> env :cascade :resource-aggregation)
>>              libraries (@aggregation :libraries)]
>>               (extend-dom dom-nodes [:html :head] :top
>>                       (template-for [asset-map libraries
>>                                           :let [path (to-asset-path env 
>> asset-map)]]
>>                               :script { :type "text/javascript" :src path } 
>> [ linebreak ]))))
>>
>>
>> Of course there are any number of ways to write this, but I prefer the
>> first option, as it does less of a job of obscuring what the main
>> point of the function is: a call to extend-dom.
>
> I don't see any obfuscation. Especially if you add a docstring "Extend
> DOM with ..." to the function.
>
> Sincerely
> Meikel
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

--~--~---------~--~----~------------~-------~--~----~
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