On Jan 23, 2009, at 17:15, Stephen C. Gilardi wrote: > I recently changed my "user.clj" file to be purely full of > definitions. I think it fits well with the "require"/"use" model > that reloading ought to only affect what's available to call after > the load, not actually "do" (in the Clojure side-effecting sense) > anything.
I do the same. > Some questions this raises: > > - Should libs be restricted to definitions (and lib support things > like "ns" and (some kind of) "load-resource") only? > > - Should the appearance of an "ns" form automatically make that > restriction enforced for the rest of "this file" (as it's being > loaded). That would require an operational definition of what counts as a "definition", which moreover can be verified by the compiler. I am not sure that is realistic. Pretty much any Clojure function except for I/O can be used in definitions, so your suggestion comes down to making the compiler recognize any attempt to do I/O, even indirectly, and even then make an exception for things like load-file. As a guideline your sugggestions seem fine though. I wouldn't like to work with libraries whose mere import does something magical. > - Do we need a mechanism like java's "main" method where we could > put any scripting code (things intended to "do" something when the > lib is used as a script) rather than allowing non-definitions > everywhere? We could by convention call a particularly named > function or we could provide the name (or signature?) of a > designated function in the "ns" form and call that when calling > (effectively) a namespace as a "program" rather than "using" it as > a "library": > > (ns my-simulator > (:require 'clojure.contrib.lazy-seqs) > (:main do-simulation [circuit inputs])) That sounds nice. Konrad. --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---