Jira https://clojure.atlassian.net/
Spelunking through source code
https://clojure.org/reference/compilation
-
Opcodes.java
-
Compiler.java
public static Object compile
a 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 ObjExpr
etc.
- see inner
-
see
(defn load
incore.java
(clojure.lang.RT/load (.substring path 1))
-
Compile.java
just amain
method 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 read
incore.clj
([opts stream] (. clojure.lang.LispReader (read stream opts)))
*read-eval*
Note that read can execute code (controlled by read-eval)...
- see also
read-string
core 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.Clojure
public 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-install
script 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.nrepl
successor isnrepl
(0.3.1
should be drop-in replacement for0.2.13
)reply
akaREPL-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.clj
definesdefn start-server
,defn default-handler
- leiningen - https://github.com/technomancy/leiningen
repl.clj
defn- server-forms
builds handler, overrideable by plugins (e.g. for additional middleware)defn- handler-for
usesnrepl-middleware
fromproject.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-middleware
ofproject.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-server
only specifying port - no hook to override middleware
https://clojure.org/reference/repl_and_main
main.java
public static void main
(refered to by jarmanifest.mf
, seebuild.xml
)main.clj
defn main
no args casemain.clj
defn repl
actually implements a repl
"read-eval" refers to reading forms (the Clojure "reader") followed by eval (can include compilation)