Hi Petr,

Did you see this?
https://github.com/clojure/tools.namespace#warnings-for-aliases

Also mentioned: "Aliases to reloaded namespaces will break if the
namespace containing the alias is not reloaded also."

I've been writing per-project wrappers over the refresh function to do
the ns-unalias+alias calls.  I wonder if it would be feasible to have
something that keeps track of just aliases in the user namespace, and
do the re-aliasing after a refresh.

Ivan

On Sat, May 3, 2014 at 4:04 PM, Petr <petrg...@gmail.com> wrote:
> Hello.
>
> I experienced non obvious behavior of "require namespace as alias" when
> using clojure.tools.namespace.repl/refresh.
> If I use aliased namespace then after changing source files and call to
> refresh I seem to have old values in that alias. If I use plain require all
> seem to work as expected, new definitions take effect after reload.
>
> For example, in first case:
> (ns a (require [b :as b-alias]))
> (println b-alias/x) ; original value
> ; change sources of b or it's dependencies
> (clojure.tools.namespace.repl/refresh)
> (println b-alias/x) ; original value
> ; and also
> (println b/x) ; new value
>
> In second case:
> (ns a (require [b]))
> (println b/x) ; original value
> ; change sources of b or it's dependencies
> (clojure.tools.namespace.repl/refresh)
> (println b/x) ; new value
>
> Can anyone explain why require acts like this? Does it mean that alias is
> not just naming change but some data structure in memory?
>
> --
> 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.

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