This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-02
Channels
- # announcements (12)
- # babashka (7)
- # babashka-sci-dev (46)
- # beginners (35)
- # biff (1)
- # calva (4)
- # cider (22)
- # clj-kondo (48)
- # clj-on-windows (4)
- # clojure (132)
- # clojure-europe (161)
- # clojure-germany (1)
- # clojure-nl (2)
- # clojure-uk (5)
- # clojurescript (39)
- # conjure (10)
- # core-typed (1)
- # cursive (48)
- # datalevin (6)
- # datascript (12)
- # datomic (9)
- # emacs (5)
- # events (1)
- # figwheel-main (2)
- # honeysql (7)
- # hyperfiddle (35)
- # improve-getting-started (8)
- # introduce-yourself (4)
- # london-clojurians (1)
- # off-topic (20)
- # podcasts (1)
- # re-frame (45)
- # reitit (5)
- # releases (2)
- # rum (7)
- # shadow-cljs (20)
- # spacemacs (4)
- # tools-build (58)
- # tools-deps (19)
- # xtdb (56)
so, defmacro defines a function who’s arguments are not evaluated until encountered by ~symbol syntax as if normally executing
But since macros are functions from a data structure to another data structure it is very convenient to use it
Clojure code is read by the reader producing a data structure, a tree of all the literals clojure supports, then that tree is what eval operates on, and as part of evaluating that tree, before anything else, if what is being evaling is a macro call, the arguments to the macro (as the data structure returned from read) are passed to the macro, and then the data structure returned by the macro is evaluated in place of the call to the macro
Most of the control restructures in clojure are macros (are written in clojure in terms of simpler control structures the compiler understands)
E.g. dotimes is a macro (a function) that takes the binding form (a vector) and a body (whatever) and emits a data structure that is a loop/recur loop incrementing a counter and evaling body each time through the loop
You can see this if you use something like macro expand, or just look at the source of dotimes
Like, if you want to implement a lisp, please read something, anything about how lisps work and how they are implemented
Like even structure and interpretation of computer programs, which I don't think delves into macros, but it at least sketches out the basics of a lisp interpreter
I think I saw chouser is running a reading group for Lisp In Small Pieces in clojure
LISP is a survey of the language design space around a lisp, different features they can have and how to implement them
Hi everyone, do watch calls occur in order when set on a ref
?
These two bits from the docs confused me :
The watch fn will be called synchronously, on the agent's thread if an agent,
before any pending sends if agent or ref.
And then a couple of lines after :
Note also that watch fns may be called from multiple threads simultaneously.
First line is about one thread context. Second outlines the behavior in multithreaded case
Thanks @U04V4KLKC You mean that the watch will be called on the same thread that is changing the ref itself ?
How do I load an additional namespace into a REPL? require? use? import?
require
finds and loads clojure code, use
does the same, and pollutes the current namespace, import
creates a shorthand for a Class (classes are loaded automatically when referenced, import lets you specify File
instead of java.io.File
for example)

thank you!
also useful to be aware of: https://clojuredocs.org/clojure.core/load https://clojuredocs.org/clojure.core/load-file https://clojuredocs.org/clojure.core/loaded-libs https://clojuredocs.org/clojure.main/load-script
thanks!