Jira https://clojure.atlassian.net/
Spelunking through source code
https://clojure.org/reference/compilation
-
Opcodes.java -
Compiler.javapublic static Object compilea good starting point, see how it concludes with getting byte array from class writer/visitor and writing it to a class filepublic static Object eval(Object form)- see inner
interface Expr#eval,class ObjExpretc.
- see inner
-
see
(defn loadincore.java(clojure.lang.RT/load (.substring path 1)) -
Compile.javajust amainmethod that invokes corecompile -
core
defn compile -
Symbol.java,intern() -
Var.java,setDynamic() -
Intrinsics.java
https://clojure.org/reference/reader see also https://clojure.org/reference/evaluation
-
LispReader.java -
see
defn readincore.clj([opts stream] (. clojure.lang.LispReader (read stream opts)))*read-eval*
Note that read can execute code (controlled by read-eval)...
- see also
read-stringcore function
-
EdnReader.java -
See also
tools.reader: a reader implemented in Clojure, replacesLispReader
Alex
You can invoke the Clojure.read() function to read a literal map or Clojure.var() to look up Clojure vars and invoke them
- This ^ refers to
clojure.java.api.Clojurepublic static Object read(String s)public static IFn var(...)overloaded
Starting REST API
-
compojure - https://github.com/weavejester/compojure
$ lein new compojure hello-world $ lein ring server -
see also
- CLI tools (1.10.1.763) plus dot-clojure repo/aliases
- VS Code + Clover + Socket REPL
- possible with lein, nREPL, emacs/vi/cursive
- tools.deps.alpha's add-lib3 branch to add dependencies to running app (can use Pomegrante with lein for same thing)
- Reveal (optional, supliment editor) see also: REBL (Cognitect)
- clj-kondo (borkdude)
- strict paredit
- parinfer
- tap
- selmer templating (similar to django, see also hiccup)
- spec
- Cryogen clojure markdown
require -
- must require ns before using
load -
use -
Require isn't thread-safe https://ask.clojure.org/index.php/9893/require-is-not-thread-safe
- core
defn- serialized-require,defn requiring-resolve clojure.lang.RT/REQUIRE_LOCK
Install from the official tap (not the homebrew built-in formula)
brew install clojure/tools/clojure
https://clojure.org/releases/tools
installed clj, rlwrap https://clojure.org/guides/getting_started
Use the
linux-installscript to download and run the install, which will create the executables/usr/local/bin/clj,/usr/local/bin/clojure, and the directory/usr/local/lib/clojure:
According to Alex
tools.build is coming...
The brew-install repo contains the installed scripts including (confusingly) the
linux-install.sh script
commands
man clojure
clojure -X:deps tree
lein leiningen repl nrepl tools.nrepl cider repl-y reply
tools.nreplsuccessor isnrepl(0.3.1should be drop-in replacement for0.2.13)replyakaREPL-y- a replacement for stock Clojure repl, unrelated to nrepl (but with integration)
Upgrade a bunch of other packages including cider. As a reminder to self, then had to go update
version of cider-nrepl to match, in both ~/.lein/profiles.clj and ~/.gradle/gradle.properties.
tools.nrepl- https://github.com/clojure/tools.nreplserver.cljdefinesdefn start-server,defn default-handler
- leiningen - https://github.com/technomancy/leiningen
repl.cljdefn- server-formsbuilds handler, overrideable by plugins (e.g. for additional middleware)defn- handler-forusesnrepl-middlewarefromproject.clj
cider-nrepl- https://github.com/clojure-emacs/cider-nrepl- additional middleware for
tools.nrepl plugin.clj(lein plugin) adds its own middleware to:repl-options :nrepl-middlewareofproject.clj- See
~/.lein/profiles.clj- this sets the lein repl plugin
- additional middleware for
gradle-clojure- https://github.com/clojurephant/clojurephant- gradle plugin providing simple clojure support
clojure_nrepl.clj- simply callsnrepl/start-serveronly specifying port - no hook to override middleware
https://clojure.org/reference/repl_and_main
main.javapublic static void main(refered to by jarmanifest.mf, seebuild.xml)main.cljdefn mainno args casemain.cljdefn replactually implements a repl
"read-eval" refers to reading forms (the Clojure "reader") followed by eval (can include compilation)