On Friday, December 30, 2016 at 10:13:49 AM UTC-6, Mars0i wrote: > > I love Clojure. But: My number one complaint about it is that the > compiler won't allow cyclic namespace dependencies. I am not a > compiler-writer, but as far as I can tell the only reason for this > restriction is ... philosophical. It forces bad code organization, and it > wastes time. Those who think that cyclic code is an evil are free to > encourage its avoidance. I'm happy to avoid it! But sometimes I can't. I > absolutely hate the cyclic namespace restriction. Drives me crazy when I > am forced to encounter it. > > First of all, there is no such restriction. So there is no reason for it, philosophical or otherwise. It is true that if you declare all your dependencies in ns forms, you will get an exception with cyclic namespaces. That's a *good* thing -- the result probably wouldn't be what you want anyway. However, there's no requirement that all dependencies be declared using ns -- you can use require at any time.
What *is* required is that all the vars a form uses exist when it is compiled. The reason for this is purely technical -- resolving symbols to vars at compile time means less work (more efficiency) at run time. > My latest case is that I'm trying to debug a weird Java interop > problem--something that works in one app I've written, in which I ended up > putting most of the application into one file, but doesn't work in the one > I'm working on now. And I had finally come up with a clever way of > avoiding sticking most of the code into one namespace. I'd worked around > the conflict between Clojure's requirements and the requirements of the > Java library I'm using. But now there's this one problem, and I want to > try an experiment to see whether it fixes the problem. It looks like I'm > going to have to pack all of the code into one file and rewrite everything > that that necessitates just for this purpose. Aghh. > > Perhaps if you provided a coherent description the specifics of your problem, someone would be able to suggest a satisfactory solution. > I have sometimes ranted a bit in this group, and in the end some of my > rants were unreasonable. I don't think this is unreasonable. The cyclic > dependency restriction is absurd. I'm not trying to start a flame ware. I > feel strongly about this, and I'm frustrated. > > What would be reasonable is asking questions about things until you understand them well enough to be in a position to make an informed opinion. In this case: 1. Clojure does allow namespaces to refer to each other (just maybe not how you've tried). 2. There are plenty of technical considerations when it comes to mixing dynamic languages and cyclic references. Cyclic namespaces are a subset of this problem. So describing restrictions on cyclic namespaces (whether real or imagined) as "absurd" is absurd. A rant is just a rant, regardless of whether a problem actually exists. If you feel strongly about something and only rant about it, don't be surprised when you feel frustrated. Frustration can be relieved by solutions. If you don't understand the problem enough to present a solution, ask questions until you do. Don't expect others to do all the work -- *especially* after ranting about it. > What I want: I'm not trying to make everyone sit around tapping their > fingers while code to goes through multi-pass compliations. All I'm asking > for is a compiler option that will allow cyclic dependencies when requested. > > I don't think multi-pass compilation would play well with things like macros or REPL-based development, so I doubt we'll have to worry about that. > I'm pretty sure that the way I've put things above illustrates some > ignorance on my part, but still ... how hard can this be? It's a > reasonable thing to ask of a sophisticated compiler. > > Questions like "How hard can this be?" are not only unconstructive, but they also belie your sincerity in resolving your self-claimed ignorance. -- 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.