On Sunday, June 1, 2014 9:36:55 AM UTC-5, Glen Mailer wrote:
>
> Hi everyone, I'm looking to get some opinions on code style.
>
> Specifically, I like to write my code in a top-down.
>
> What I mean by that is that within a file the highest-level functions sit 
> at the top, and are implemented in terms of lower-level functions further 
> down.
> ...
> There's a few approaches i've seen from reading other's code:
> ...
> Some other options I considered include making really heavy use of 
> (declare), ...
>

I'm puzzled by the complexity of the solutions proposed.  (Although I like 
Luc's, since my computer doesn't have an auto-rotate function.)  I don't 
see this as a big deal at all. I just put a big declare statement at the 
top of the file.

More specifically, when initially coding related functions, I'll put the 
dependent ones below the ones they call.  After that chunk of code is done, 
I might move the higher-level functions up in the file.  Then I add the new 
functions to the declare statement by hand, or I periodically do something 
like:

grep defn mysourcefile.clj >> mysourcefile.clj
(Be careful to use two ">"s!)

and then I edit the junk at the end of the file into a declare statement at 
the top of the file.  And maybe if f I were ... lazier, I'd code a script 
that would update the declare in one pass.

That works for defn and defn-, and you might want to shorten the search 
term to 'def'.  It's more difficult if you use Clojure protocols.

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