Fork me on GitHub
#beginners
<
2023-11-02
>
Kari Marttila10:11:26

I'm learning some legacy Clojure code base in a new project. There is a lot of:

(def foo
  {:compile (fn [...
I tried to find information about this :compile keyword in def, but couldn't find much info about it. I guess this is some aot compilation stuff? foo is used in some middleware processing. Is this necessary in some middleware processing? Why not just regular (defn foo [] ... ?

delaguardo10:11:19

{:compile (fn [... has nothing to do with clojure compiler. This is just "define foo as a map with key :compile"

Kari Marttila11:11:32

Ah, of course. It's been more than a year since I have done anything with Clojure. Thanks. 🙂

Kari Marttila21:11:04

Damn. I'm really ashamed of myself. A really rookie misunderstanding. Shame on you, Kari! 🙂

Kari Marttila21:11:22

But I must say that I miss Clojure. Sometimes I ask myself that did I make a good choice switching Clojure to a considerably bigger pay check. 🙂

Raúl Sánchez Ruiz14:11:22

Hi @everyone! I’m interesting on Clojure and babashka. At this moment I’d like to create two different projects. Firstly I need to create an azure template generator following a specific pattern. The other project it’s a dashboard of azure boards and working items. In your experience what do you think about making that projects with clojure or babashka? Thanks for your time reading this!

borkdude14:11:37

It's easy to switch between both so you don't really have to choose :)

borkdude14:11:06

bb is more limited but more light-weight (faster to start), if you run into a limitation you can still switch to JVM Clojure.

borkdude14:11:47

Feel free to join #CLX41ASCS if you have any bb-specific questions

Raúl Sánchez Ruiz14:11:07

Thanks for the answers @U04V15CAJ! I’m really interested in the announcement of self contained binary for babashka. I’ll try to find the library’s or utils for start with generator and cli and ask in the bb channel if have doubts 😃

Andrew Meiners19:11:41

Does anyone know of any open source Clojure projects that a beginning dev might be able to fire up a REPL and learn their way into contributing? Maybe with some relatively low hanging fruit issues that may still need a bit of fiddling in the REPL to understand what is going on

djblue20:11:06

I work on this tool called https://github.com/djblue/portal and there is this https://github.com/djblue/portal/issues/68 that could use some work. The code base isn't particularly small, but the issues should mostly be isolated to the https://github.com/djblue/portal/blob/master/src/portal/runtime/browser.cljc#L23-L32 namespace. The underlying problem is allowing users to specify the name of a binary of a chromium based browser to use instead of the default chrome.

Andrew Meiners20:11:13

Very cool! I've seen several Clojure talks about Portal. I'll check it out!

Matt Ielusic20:11:39

What’s the most idiomatic way to assert that a macro argument is always a Var?

ghadi21:11:39

try it, that will not work

ghadi21:11:57

macros receive unevaluated forms

Matt Ielusic21:11:45

Hmmm, yeah, I’m doing maintenance work on a legacy codebase and I do wish that first rule you mention had been followed more closely – that it depended on fewer custom macros.

Fredrik11:11:42

I guess something like

(defmacro my-macro [v]
  `(let [v# ~v]
     (if-not (var? v#)
       :not-a-var
       ...)))
could work. The reason for introducing v# is just to make sure we don't evaluate the input expression v more than once. If you know there's never any side-effects evaluating v, then it's not strictly necessary.

Matt Ielusic18:11:22

That’s an interesting approach, but the assert is executed immediately, not in a ns-quoted block I think the idea is to make ns loading fail the instant it tries to expand a macro with bad args

Fredrik16:11:19

I guess then your macro must call eval on it's arguments, and check if the result is a var or not.

λ22:11:10

I am really trying to understand the concept of functional core imperative shell. Does anyone have a good resource that demonstrates this?

emccue22:11:45

I can rant at you a bit

emccue22:11:49

if that would help

emccue22:11:12

but the basics is the the places in the code where you "make a choice" you don't do mutation or side effects

emccue22:11:25

the places where you actually affect the world or need to gather information from the world, you go wild

emccue22:11:23

since most programs are "talk to the world" -> "think" -> "talk to the world", that is a "shell" around "thinking"

emccue22:11:05

(let [stuff (make-http-request client)]
  (when (should-do-thing? stuff)
    (save-to-database conn (shape stuff)))

emccue22:11:44

so the goal is to put as much of your program in should-do-thing? and shape as you can

λ23:11:16

Do you have code examples on a forge somewhere that I could take a look at?