Hello. 

 I stumbled on a problem that caused me fair amount of frustration and I 
suspect that it could affect other users who start using tools.namespace. 

The problem is that clojure.code/ns macro is more lenient than what follows 
from it’s documentation. For example ‘use’ (or require) clause in vector is 
accepted e.g. “[:use ....]” (see http://dev.clojure.org/jira/browse/TNS-21) 
or use clause with plain symbol (not keyword) is also OK, e.g. “(use ....)" 
(as in my case http://dev.clojure.org/jira/browse/TNS-30). And the way ns 
macro is expanded section in form “(aaaa ....)” would be replaced with 
“(clojure.core/aaaa ... )”. However tools.namespace parses dependencies 
strictly according to doc. E.g.TNS-21 was closed as won’t fix for that 
reason. 

 This way there could be ns declarations  that have no compilation errors 
and work as one may think but are ignored by c.t.n’s parser.  Hence there 
could be actual dependencies that are silently ignored without any error or 
warning. 

 It seems that proper way to resolve this would be to rewrite ns macro to 
be more strict and accept only what’s described in documentation. But I 
suspect that this would lead to backward compatibility issues - some of 
existing code will break. 

 There is also possibility to rewrite 
clojure.tools.namespace.parse/deps-from-ns-decl so it does macroexpand and 
then looks for references to clojure.core/refer, clojure.core/require and 
clojure.core/use. This would match now ns actually works but one might not 
like this “implementation as specification”. 

 So I think that the good solution for now would be to have some validation 
function forns form. This function would issue a warning when some parts of 
namespace declaration could be ignored. This way unexpected behavior of 
clojure.tools.namespace.repl/refresh would not go unnoticed and this will 
make this library more user-friendly. 

What do you think would be a good solution for this?


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