On 8/25/15 12:06 AM, Kurt Sys wrote: > I'm refering to a few posts in an old thread: > https://groups.google.com/d/msg/clojure/r_ym-h53f1E/RzUdb5oYeX4J > > What really puzzles me is that it doesn't seem to be generally > regarded as idiomatic Clojure style to just use top-level (let)s for > your "private" globals. > > > So, here's the question: what's considered best practice in Clojure > (what is idiomatic in Clojure): using private (namespace-scoped) globals > variables or one big let over all (or at least, most) defns in a > namespace? And why :)? >
I have found the access control stuff in Java to be an incredible pain. When attempting to compose a larger system from the parts. Generally everything is compulsively private, so if an api doesn't exactly expose what you want, you either have to write what you want completely from scratch, or use reflection to get a the bits you want to compose in to what you want. Avoid private as much as you can, and if you think you can't, ask yourself, is this really private or is it a bit of instance state that really shouldn't be a global def anyway. When I make the case for making everything public generally the argument I get back is about api evolution and how do users know what the stable parts of the api are? I think this concern is a result of using languages and tooling that don't do a good job of distinguishing source code used to build an artifact and an artifact. Clojure tooling is mostly built on top of maven, which does an excellent job of distinguishing between the two. If you build your code using a jar out of maven with a fixed version of 1.0.1, unless you change your dependency you will always get the same code, so who cares what the author decided is the stable public api and what is the private api. Anything that you can make use of you can, and it will be the same until you change it. The answer to that is generally something about semantic versioning, which due to every high profile project that uses it having at some point a heated argument about what does and does not constitute a patch release, who knows what you getting anyway. -- And what is good, Phaedrus, And what is not good— Need we ask anyone to tell us these things? -- 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.