Stuart Sierra said:
"Yes, it is incorrect, in both Clojure and ClojureScript, to repeat
the (:require ...) or (:use ...) forms in an `ns` declaration."
Based on code from Aaron:
>
> (ns my-namespace
> (:require [lib1 :as l1])
> (:require [lib2 :as l2]))
This doesn't compile correctly for ClojureScript:
> The compiler misses the first require.
I've run into this as well but was able to reorganize my code to avoid
the issue so I didn't spend any time chasing it down.
Stuart's response really surprised me because:
a) multiple :require's work fine in Clojure (JVM)
b) lots of examples / blogs etc out there show multiple :require's -
including the 8th light blog about "namespaces, use and require" which
everyone gets referred to
c) lots of existing code uses multiple :require's etc
If multiple :require's is really incorrect, shouldn't the `ns` macro
output at least a warning? (in Clojure JVM, CLR and Script) And all
the documentation out there needs to be updated...
If multiple :require's is supposed to work, then this is a bug in ClojureScript.
What's the definitive position here?
FWIW, Clojure in Action has at least one example with multiple
:require's and Joy of Clojure has at least one example with multiple
:use's so the written / printed word also seems to think this should
work. Programming Clojure seems to be very careful to have at most one
of each. I don't have a copy of Practical Clojure on hand to check
that.
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)
- Cosmin
> --
> You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
> To post to this group, send email to cloju...@googlegroups.com.
> To unsubscribe from this group, send email to clojure-dev...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/clojure-dev?hl=en.
>
--
Cosmin Stejerean
http://offbytwo.com
To this specific point, if the consensus is that this shouldn't be
allowed in Clojure, then I'm happy to update my blog post to reflect
that. In such a case, perhaps the docstring could be clarified a bit
to make that more obvious? It wouldn't be strictly wrong as-is, but
could be more helpful.
> c) lots of existing code uses multiple :require's etc
>
> If multiple :require's is really incorrect, shouldn't the `ns` macro
> output at least a warning? (in Clojure JVM, CLR and Script) And all
> the documentation out there needs to be updated...
> If multiple :require's is supposed to work, then this is a bug in ClojureScript.
>
> What's the definitive position here?
>
> FWIW, Clojure in Action has at least one example with multiple
> :require's and Joy of Clojure has at least one example with multiple
> :use's so the written / printed word also seems to think this should
> work. Programming Clojure seems to be very careful to have at most one
> of each. I don't have a copy of Practical Clojure on hand to check
> that.
I don't see any examples of it in Practical Clojure.
> --
> Sean A Corfield -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
> World Singles, LLC. -- http://worldsingles.com/
>
> "Perfection is the enemy of the good."
> -- Gustave Flaubert, French realist novelist (1821-1880)
>
> --
> You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
> To post to this group, send email to cloju...@googlegroups.com.
> To unsubscribe from this group, send email to clojure-dev...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/clojure-dev?hl=en.
>
--
Colin Jones
@trptcolin
"Yes, it is incorrect, in both Clojure and ClojureScript, to repeat
the (:require ...) or (:use ...) forms in an `ns` declaration."
I'm not sure I understand what you mean by that. What else about the
ns macro is an implementation detail that should not be relied upon?
I'm not sure I understand what you mean by that. What else about the
ns macro is an implementation detail that should not be relied upon?
I'll agree with all of that. (ns foo (use blah)) is a good example of
something that works but probably shouldn't.
I get the impression that (:import ..) requires lists but (:require
..) and (:use ..) accept vectors - and you're saying that should be
cleaned up? (given the prevalence of vectors for :require/:use,
:import should accept vectors, yes?)
Perhaps Clojure/core could write a definitive spec of what `ns` should
too and we can take a look at the delta between what's supposed to
work and what actually works (and what is commonly expected to work)?
The status quo is certainly a problem and the longer we leave it, the
harder it will be to restrict `ns` to just what is intended to work vs
what works by accident - and this will become increasingly important
as alternative Clojure implementations appear / grow (CLR, Script,
Python...).
I completely disagree on this one, personally.
1) This would make the interop form "more powerful" than the native
one. Why do you want me to repeat "clojure" over and over here?
https://github.com/remleduff/CinC/blob/master/src/clojure/java/compiler.clj#L5
2) Lists should be used for things that look like invocation. (:use)
is appropriate, (java.util List) seems wrong, nothing is being invoked
and "should" be quoted in normal clojure. Vectors are much more
appropriate in my highly opinionated view. :)
> - No bare symbols in :import
This just seems like a gratuitous difference between :use/:require and
:import, though I do almost always end up using prefix lists for
:import.
stuart's example here is incorrect, correct it looks like:
https://gist.github.com/1996557
> --
> You received this message because you are subscribed to the Google Groups
> "Clojure Dev" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/clojure-dev/-/apV9oNtMX3oJ.
>
> To post to this group, send email to cloju...@googlegroups.com.
> To unsubscribe from this group, send email to
> clojure-dev...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/clojure-dev?hl=en.
--
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?
stuart's example here is incorrect, correct it looks like:
well, I don't write clojurescript, I write clojure were bare symbols
are supported, but they are still incorrect
> --
> You received this message because you are subscribed to the Google Groups
> "Clojure Dev" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/clojure-dev/-/uCye7T83BW8J.
Wait, is this one still your opinion or is it fact? :use is
deprecated? I'd be very dismayed if that were the case. It's a bad
practice in a lot of coding environments, sure, but it's indispensible
when live-coding overtone.
Phil