I have just been working for the last day on adding code to the Eastwood
Clojure lint tool [1] for checking these and a few other things about wrong
ns forms.  The documentation I just wrote for what it will do is here [2].

No released version of Eastwood makes these checks yet.  I will probably
release the first Eastwood version that does within the next 1 to 3 weeks.
There are instructions in Eastwood's documentation for using the latest
unreleased version if you are interested on being on the bleeding edge [3].

If anyone has thoughts on other things to warn about in wrong ns forms,
please reply to this thread, or create an Eastwood issue on GitHub.  The
only other change I have in mind right now is perhaps not warning if
someone uses :include-macros in :require, because it appears that has snuck
into the :require's of several projects that are both Clojure/Java and
ClojureScript.  I will first verify that this option is ignored by
Clojure/Java before eliminating such warnings.

Andy


[1] https://github.com/jonase/eastwood
[2]
https://github.com/jonase/eastwood/blob/master/README.next.md#wrong-ns-form
[3] https://github.com/jonase/eastwood#for-eastwood-developers


On Sun, Dec 14, 2014 at 1:58 AM, Petr <petrg...@gmail.com> wrote:
>
>   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.
>

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