I've found the requirement to define things in order to be a major pain in the following reasonably common situation:
A) public API in one namespace B) various functions used to implement public API in another namespace A clearly depends on B. But B often needs to depend on A also: you typically want to use calls to the public API as part of your implementation (e.g. recursively processing subcomponents in a tree-like data structure) I haven't found a good solution to this yet in Clojure. Typical workarounds involve duplication / facades, such as having "api-function" in A call "api-function-impl" in B. My personal opinion (before anyone starts flaming - please regard as constructive criticism) is that Clojure is weak in this regard. Even if it is possible to make this sort of code work, expecting developers to jump through hoops, restructure their code and/or spend a lot of time refactoring because the language doesn't support proper forward declarations is not great..... Clojure would be a better language IMHO if the environment allowed arbitrary declaration order and I think this could feasibly be achieved (via some judicious compiler / namespace handling enhancements). On Saturday, 17 August 2013 00:53:23 UTC+8, Stuart Sierra wrote: > > Forward declarations are rarely necessary in my experience: you just get > used to defining your namespaces with low-level primitive functions at the > top and higher-level functions at the bottom. You only need forward > declarations (`declare`) in cases of mutual recursion, i.e. two functions > that call each other. > > -S > > > > On Wednesday, August 14, 2013 8:56:06 AM UTC-4, Phillip Lord wrote: >> >> >> One of the things that I find unusual with clojure is the requirement >> for forward declaration. While I can see the advantages, managing it by >> hand can be a pain. >> >> So I was wondering, are there any tools for adding declare statements >> when necessary. And better for working out how to reorder function >> declarations to minimize the requirement for forward declarations. >> >> Phil >> >> -- -- 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/groups/opt_out.