As a complete clojure newbie (hi folks!) from a Ruby/Java background,
I kind-of don't like either - I'd pull out a named function like:
(def add-mix-and-beat [bowl, dry-ingredients wet-ingredients] ...

and then use your second example, but now it's:

(def make-cookies-2a [flower baking-soda salt button sugar eggs]
  (bake (make-dough-balls
    (find-baking-sheet)
    (add-mix-and-beat (find-bowl) '(flower baking-soda
 salt) '(eggs flour)))

- I'm trying to follow the "if it does more than 7 things, it's too
complex" model.

(Apologies if my syntax is broken - I'm still completely new to
lisp/clojure (ok, I did lisp at uni, but that's an embarrassingly long
time ago!))

- Korny

On Thu, Jan 8, 2009 at 8:17 AM, Mark Volkmann <r.mark.volkm...@gmail.com> wrote:
>
> On Wed, Jan 7, 2009 at 3:05 PM, Tom Ayerst <tom.aye...@gmail.com> wrote:
>> Honestly?  The second one, but I did say I didn't like the 'big let' style,
>> maybe that is why.
>
> I think I may be in the minority on this. I suspect there are more
> people currently using Clojure who came to it from a Lisp background
> than a Java background. I had exposure to Lisp in college, but that
> was a long time ago. My recent experience has been more with Java and
> Ruby. Maybe that's why I find deeply nested function calls difficult
> to read. After three or four levels of nesting, the code is no longer
> obvious to me. The second option below is six levels deep.
>
>> Cheers
>>
>> Tom
>>
>> 2009/1/7 Mark Volkmann <r.mark.volkm...@gmail.com>
>>>
>>> On Wed, Jan 7, 2009 at 3:13 AM, Tom Ayerst <tom.aye...@gmail.com> wrote:
>>> > Hi Mark,
>>> >
>>> I agree they could be inlined, but I find that style easier to read.
>>> For example, these are equivalent.
>>>
>>> (defn make-cookies-1 [flower baking-soda salt button sugar eggs]
>>>  ; let describes the step-by-step process for making cookies.
>>>  (let [bowl (find-bowl :small)
>>>         bowl (add-ingredients bowl flower baking-soda salt)
>>>         batter (mix bowl)
>>>         batter (add-and-beat batter eggs flour)
>>>         baking-sheet (find-baking-sheet)
>>>         baking-sheet (make-dough-balls baking-sheet batter)]
>>>    (bake baking-sheet)))
>>>
>>> (def make-cookies-2 [flower baking-soda salt button sugar eggs]
>>>  (bake (make-dough-balls
>>>    (find-baking-sheet)
>>>    (add-and-beat (mix (add-ingredients (find-bowl) flower baking-soda
>>> salt) eggs flour))))
>>>
>>> Which of these is easier to understand?
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
>
> >
>



-- 
Kornelis Sietsma  korny at my surname dot com
kornys at gmail dot com on google chat -- kornys on skype
"Every jumbled pile of person has a thinking part
that wonders what the part that isn't thinking
isn't thinking of"

--~--~---------~--~----~------------~-------~--~----~
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 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to