Fork me on GitHub

@mss The splice operator might be what you're looking for here inside a macro definition: ~@ see

👍 4

thank you!


Forgive a somewhat confused question from the perspective of someone who has been interests in lisps for a long time but only recently realized Clojure was a thing... the “data as code thing”. I’m curious (honestly so) about in what sense/senses that is true, or maybe more correctly relevant. Especially as compared to other relatively main stream languages...


It occurred me to consider this, as I suspect but haven’t verified that I probably can’t access Clojure code as actual data at runtime? If I can actually insert an sexpr into a function in runtime the question pretty much falls 😅


@mattias504 Code is just a series of lists and vectors etc. For example (list 'def 'foo 42) produces (def foo 42)


Macros are functions that are run on the code forms before they are compiled and run. So they are just transformations of data structures, that accept code as input and produce code as output.


Hmm. So code is data to macros but not (you can kill me now 😛) to “real” code?


Oh, and thanks a lot for having the patience to answer! Appreciated 😄


(defmacro make-foo [v] `(def ~'foo ~v))
for example, so
(make-foo 42)
will produce
(clojure.core/def foo 42)
which is then compiled and executed


If you said

(make-foo (+ 40 2))
it will produce
(clojure.core/def foo (+ 40 2))
-- the arguments are "just code", not evaluated.


There's a function eval that you can pass data to at runtime and it will attempt to compile and run it.


user=> (eval (list '+ 40 2))


In this case the argument is evaluated -- eval is a regular function -- and so it's the same as (eval '(+ 40 2))


(hopefully that clarifies rather than confuses?)


Very cool. Will need to take some time to digest this, thanks. On my mobile now so will be back later, wiser 😀


This code as data thing looks confusing but promising

Kari Marttila13:12:22

I need one gen-class for using a Java library from Clojure. I tried to find information where to call the compile function for that class in the application. Now using REPL is a bit problematic since when reloading all namespaces in REPL the gen-class is not found.


Can anyone recommend any content that provides a solid walkthrough of a web application using Clojure, deps.edn, scss, hiccup (or similar), that does not include anything to do with Luminus or Clojurescript? I'm looking for as basic as possible so I can get a grasp on the simple tooling things before stepping up into the more complex. It seems as though almost everything jumps straight into Clojurescript, Figwheel, Om, Re-frame, Luminus.... or it has a walkthrough but doesn't include things like scss, or even Garden for that matter. I've ran out of options in my google searching, I'm hoping something exists and I just missed it somehow. I can figure out the syntax of each library. My confusion lies in, for example, how to compile scss (or Garden, but would prefer scss) into a Clojure web app that doesn't use Clojurescript, Luminus or any of the other things I listed above that I'm not interested in at this time. Any suggestions to content would be appreciated... thank you.

👍 8

@UAW40E21F I might be able to show an example if I can better understand what you are looking for: It sounds like you are not interested in a SPA of any kind and you just want to see what it looks like to serve up a simple server side web app with Clojure, yes?


That is accurate. Including compiling and pulling in scss, using deps.edn to build, and any other handy things you might see fit.


I found Edge to be helpful It does an excellent job of showing a Clojure web app with all kinds of goodness using the latest and greatest. Be warned, there is a lot going on and knowing the bare minimum requirements is a little difficult if you are not familiar with Clojure. I found the basic tooling and project structure matched my own sensibilities so much so that I took some time to break down what I saw as the “core” components of Edge: Its not done, and Edge has changed a bit since I did my first run through, but reveng-edge should provide some of the core things you are looking for. For example, if you want to see what at the most basic serving some text would look like, you would checkout Once you see that, you might want to add the reloaded-workflow so you would check out the additions here: You may want to add server side rendered templates so checkout this If you do not want the reloaded workflow, just review web-server/reloaded-workflow and compare it to SSR-templates. The SSR Templates one might be more of what you want as it is clearer to see how you can 1. Add routes 2. serve HTML from the server and 3. add CSS to your html (I do not include CSS, but I can guide you through that in DM if you need)

👍 8

I know you were looking for more of a guide/blog post, but I have not come across any outside of luminous. Most of what is available are example projects like Edge or

Kelly Innes21:12:52

In case this is helpful: I've been trying out ClojureScript/Reagent by setting up a single page app with Leaflet, which is something I'd usually do with JS/React/Redux at work. The repo is here:

Kelly Innes21:12:20

So far I have 1. set up development and production builds 2. set up using a JS-library, Leaflet, 3. set up some app-state Reagent atoms with a minimal thing to persist the map zoom level in local storage, 4. added some linting stuff using cljfmt, kibit and bikeshed

Kelly Innes21:12:40

I skipped doing re-frame for now because although I like it conceptually it feels like a lot to take on when just starting out.


Thank you for all the resources. Apologies for not responding sooner, got caught up running errands. Very appreciated to everyone that has responded so far. I'll take a look at all the links

Kari Marttila19:12:39

Gen-classes are pretty nice way to create simple Java classes that are needed e.g. when using some Java library via Clojure/Java interop. The only major issue I had was how to use REPL effectively with gen-classes. My standard procedure to refresh everything: (do (require '[ :refer [refresh-all]]) (refresh-all)) (compile 'my-gen-class) ... didn't work with REPL - REPL used the older version of gen-class and I had to restart REPL every now and then which was a bit of a nuisance.


hi, people. It seems I can't find what is session lenght of ring-session and how can I set it to something


Looking through the source there may be two parts to adjusting session length: The first being :cookie-attrs which can have an :expires date or :max-age the second being the store you use which by default is the mem store.