33

I'm just trying out ClojureScript, starting out by converting something I wrote in Clojure into cljx.

When I try to compile it I get:

clojure.lang.ExceptionInfo: :refer must be followed by a sequence of symbols in :require 

I'm finding some oblique references online, but nowhere where it's spelled out whether I should be able to use a :refer :all in a ClojureScript program.

If I can't do it, what's the reason for this restriction?

0

1 Answer 1

50

No, it's intentionally not possible. There was a conversation on the ClojureScript mailing list recently related to :refer :all and it looks like it will never be supported.

To quote David Nolen from that thread:

It's just bad style and as far I know the only reason it hasn't changed in Clojure is because the core team is very adamant about preserving backwards compatibility when possible. The conspicuous lack of naked :use in ClojureScript was intentional.

3
  • 1
    Can someone explain why it would be bad style? Is it preferred to have one large name space instead of two, even if you can see a natural division between lower level functions and higher level exported functions? Commented Feb 18, 2017 at 0:43
  • 4
    Another problem with naked :use or refer :all is that it introduces a static phase separation. If you do (ns my-ns (:require foo.bar refer :all)) now, then add foo.bar/baz later, you might conflict with a baz already defined in my-ns. Using "all" means you must be able to enumerate the closed list of declarations in the namespace or risk super confusing interactive and partial recompilation behavior. This is especially problematic if you have macros. Commented Feb 28, 2017 at 4:13
  • It's bad style because when you try to read and understand a namespace that does this you can't tell where the functions come from. It also makes it harder to search and replace as you refactor, move things around, etc., because you don't have a common ns prefix to look for.
    – rosejn
    Commented Jan 20, 2022 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.