I think I answered myself, looks like it does here:

try {
                  Var.pushThreadBindings(
                                RT.mapUniqueKeys(CURRENT_NS, CURRENT_NS.
deref(),
                                              WARN_ON_REFLECTION, 
WARN_ON_REFLECTION.deref()
                                                  ,RT.UNCHECKED_MATH, RT.
UNCHECKED_MATH.deref()));
                       loaded = (loadClassForName(scriptbase.replace('/', '.
') + LOADER_SUFFIX) != null);
             }
              finally {
                      Var.popThreadBindings();
               }


So now I understand, but I wonder if it makes sense. 99% of the time, it 
won't be an issue, but if you're doing anything with *ns*, you'll run into 
a situation where if you compile and bootstrap yourself through gen-class 
or clojure's java API, your code will not behave similar to when you're 
loaded at runtime or bootsraped through clojure.main or lein.

(ns dda.main
  (:gen-class))

(def should-exist "Do I exist?")

(defn -main []
  (in-ns 'other)
  (ns-name *ns*))

A bad example, but this code will work through lein, clojure.main, and when 
loaded from a REPL, but not when started from gen-class or Clojure's java 
API. Is there a good reason for the discrepancy? Shouldn't all methods to 
bootsrap your code start out with an equal initialization scheme? I would 
suggest that Clojure's java API (which I assume gen-class uses under the 
hood) should also initialize the common bindings and set the namespace to 
user. That way, all entry point always behave similarly.


On Wednesday, 21 June 2017 07:03:55 UTC-7, Didier wrote:
>
> That makes sense. Actually if you use Clojure's Java API and you require a 
> namespace and invoke a Var, it will do the same, *ns* will just be 
> clojure.core.
>
> So I get it is simply because the last thing to set ns was RT.
>
> One more question:
>
> So I assume "load" would eval ns in my namespace, setting *ns* to 
> dda.main, then it would run through the file, eval all forms, and finally 
> it would reset *ns* to the previous value. Is that correct, or is there 
> something about loading that's different?
>
> Thanks
>
>

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

Reply via email to