On Apr 13, 2009, at 3:44 PM, Greg Harman wrote:

I'd like the bootstrap file to leave the REPL in whatever namespace I
last specified with my in-ns. But I'm getting different (unexpected)
results in two cases.

Case 1: Slime: the in-ns is ignored (although expressions around it
are evaluated), and my repl is in the user ns.
Case 2: Command-line (java ... clojure.main -i ./bootstrap.clj -r) the
repl prints user->, but is actually in the correct namespace (I can
execute functions defined in that namespace directly, without
explicitly in-ns from the repl command line).

Any ideas how to get the repl to "start" in a different NS than user
and why I'm seeing different behavior in my two cases?

The "-e" and "-i" initialization arguments to clojure.main run after the repl has entered the user namespace. In Clojure, every "load" saves and restores the current namespaces around the load, so only a "- e" argument can affect the initial namespace for a repl.

This should do what you're after:

% java -cp clojure.jar clojure.main -e "(in-ns 'funky-ns)" --repl
#<Namespace funky-ns>
funky-ns=>

Regarding your Case 2 where it appeared you were actually in a namespace other than the one shown in the prompt, that's very unlikely. *ns* is the "one" true place (in a given thread at a given time) where the current namespace is stored. Could it be some code you loaded "referred" to or "used" the non-user namespace thereby bringing its names into user?

--Steve

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

Reply via email to