Hello,

There is a difference in using (require) on a namespace if it was
compiled via (compile) or if it uses plain clj source files.

The difference appears if in the source file, you have for example top
level (println) commands.

If you (require) the namespace from compiled classes, you will not
have the top level (println) command executed (it has not been
compiled, and it seems normal).

But if you (require) the namespace from the corresponding source file,
you will have the top level (println) commands executed.

Do you think that "in theory", it is normal for namespaces/libs to
have top level calls (other than ones that create and assign vars)
such as the top level (println) (or maybe something more usefull :-)
(maybe start some code that installs agents, ... ?) when loaded /
required / used ?

If yes, do you think it is acceptable to not have those top level
calls made if the lib is loaded / required / used from its compiled
version ? I imagine then that it may still be possible to make a tweak
that will be assigning a "fake" var with an expression whose return
value we don't care about, but its side effects we care about. Then,
should there be some standard way in clojure to do this kind of lib
initialization stuff ? (Some macro ?)

And also, could (compile) not allow libs to be compiled if they
contain top level calls (thus preventing the behaviour of the compiled
version differ from the behaviour of the uncompiled one) ? Or could
(compile) embed all the top level calls that are not translated into
class code in some initialization section of the ns that could then be
called at the end of the ns loading ?


Thanks in advance for your answers,

Cheers,

--
Laurent





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