2009/1/23 Konrad Hinsen <konrad.hin...@laposte.net>

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


When you load a library, there is a bunch of side effects, who are the
installation of new bindings in a new namespace.

I can imagine some libraries willing to also do installation of some static
global data that need computation at installation time, and could not, for
some reason or another, be computed lazily when the functions that need it
call it for the first time.
Do you think this kind of behaviour for a library would place it your "black
list" ?

Why I say that is that because even in the less general case of not
explicitly requiring or loading the library from runtime, but of wanting to
just 'compile' the lib, the side effect of the computations done when the
library is compiled could be embarassing in an IDE context.

That's why I keep asking if it is technically feasible or not to have a
version of 'compile that does not also load things.
I fear that it may well be as hard as the general case you mentioned
concerning I/O, but for the moment I didn't succeed in having a clear answer
to that question :'(

Cheers,

-- 
Laurent


>
>
> > - 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to