On Sun, Jul 17, 2011 at 7:33 AM, Jevgeni Holodkov <jevgeni.holod...@gmail.com> wrote: > Hello, > > Usually, when I write a program, I tend to organize the function to > keep with higher abstraction on the top and the details implementation > in the end of the file like this: > > start() { > doGenericThing1(); > doGenericThing2(); > } > doGenericThing1() { > doSpecific(); > } > doGenericThing2() { > doSpecific() > } > doSpecific() {..} > > The idea is that when I open the file I want to see the most important > stuff, not the implementation details. This is also a more natural way > of reading the code. In Clojure, however, I am forced to place more > specific functions on top of the file or I will get "Unable to resolve > symbol". Yes, it is possible to overcome by using "declare" call on > the top, but this requires manual work. Is there something more > automated which I am not aware of?
Sort of. You can use two namespaces to achieve this, one with the implementation-detail functions and then another, which (ns foo (:use ...))s the first, with the public API. People might also differ as to "natural reading order". Actually, with factual work usually one puts the motivation first, then develops the little things needed to eventually draw the big conclusion, and then develops the argument and conclusion -- but also puts the bibliography, which has the references to further sources, last. Code generally turns that last on its head; Java also wants import declarations at the top of the file, rather than the "bibliography" being at the bottom. To put the "motivation" above the "argument" and eventual "conclusion" you might want to use a comment. -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- 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