This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-24
Channels
- # beginners (100)
- # calva (11)
- # cider (17)
- # clj-kondo (2)
- # cljdoc (66)
- # cljs-dev (54)
- # clojure (77)
- # clojure-czech (1)
- # clojure-dev (42)
- # clojure-europe (3)
- # clojure-italy (8)
- # clojure-nl (17)
- # clojure-spec (12)
- # clojure-uk (41)
- # clojurescript (68)
- # cursive (8)
- # datomic (15)
- # emacs (9)
- # expound (3)
- # fulcro (14)
- # garden (3)
- # graphql (2)
- # hoplon (2)
- # lein-figwheel (4)
- # leiningen (4)
- # off-topic (22)
- # onyx (8)
- # parinfer (2)
- # planck (1)
- # re-frame (5)
- # reagent (55)
- # reitit (3)
- # remote-jobs (8)
- # shadow-cljs (35)
- # spacemacs (23)
- # sql (3)
- # tools-deps (32)
- # unrepl (8)
- # vim (25)
- # yada (5)
Does anybody have any idea why might I be getting the error
> Syntax error macroexpanding clojure.core/defn at (alpha.clj:78:1).
> #object[clojure.spec.alpha$and_spec_impl$reify__2183 0x1698fc68 "[email protected]"] is not a fn, expected predicate fn
when trying to start a REPL in the spec.alpha
project and loading the code? I did this:
$ git clone # sha 5228bb75fa10
$ cd spec.alpha
$ clj
Clojure 1.10.0
user=> user=> (load-file "src/main/clojure/clojure/spec/alpha.clj")
Syntax error macroexpanding clojure.core/defn at (alpha.clj:78:1).
#object[clojure.spec.alpha$and_spec_impl$reify__2183 0x1698fc68 "[email protected]"] is not a fn, expected predicate fn
$ java -version
java version "1.8.0_192" # running on OSX
spec is aot compiled, might be a conflict since you are forcing a load of the clj, which recompiles the protocol (yet all the old instances are from the prior protocol). should probably use load instead?
Ah, OK, thank you, that helped!
I am used to load-file
and do not really know how it works, I guess I should learn 🙂
@U0522TWDA I'm curious how you got into the habit of using load-file
in the first place? It seems like require
would be the "obvious" thing to learn first...
yeah, that seems weird
Perhaps a bad habit from Node.js where require is idempotent and does not actually reload the code from the disk.
Also, I see that Cursive's "load file in repl" used to reload the code actually calls load-file
, at least when running REPL via main (instead of via lein)
Ah, no, Clojure require
does not reload the code either
> Loads libs, skipping any that are already loaded.
So what are you saying? That the 1st time I should use require but after I change the code, to get the changes in, then I should use what?
(I guess I will get the answer after I finish Eric's REPL course)
Also, require requires that the code is on the classpath while load-file does not care about that. But I guess that is not a problem if I only use lein repl
in lein project and clj
in deps.edn projects as those have the correct paths autom.
I think editors are likely to use load-file
since they have a filesystem path, rather than a namespace -- but I view load-file
as a tooling/system-level hook. Always interesting to hear how other folks developed their Clojure habits...
or require?