On Jan 23, 2009, at 8:38 AM, Peter Wolf wrote:

Looking for opinions from Clojure internals Wizards...

I can think of only one Clojure internals Wizard, but I have some thoughts.

I am thinking about "safe loading" for IDEs (see other thread).  IDEs
need a way to load and resolve code, without calling script code that
might be in the file.

That's interesting and it seems arguments along these lines touch on topics like "functional" vs. "imperative" as well with "functional" having many of its usual advantages here as well.

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.

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).

- 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]))

This seems an attractive model for libs independent of its usefulness for IDEs and with IDEs benefiting so much from it, I like it a lot.

--Steve

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to