beginners

2025-09-15T11:05:13.282599Z

Hi, everyone! Is there some debugging trick/lib to get evaluation output on each step of a threading macro?

p-himik 2025-09-15T11:45:09.029539Z

You can inspect any particular step in (-> ...) with (doto prn) or something like that. And with (#(doto % prn)) in (->> ...). And if you want to inspect every single step, there are multiple libraries with suitable functionality, e.g. https://github.com/philoskim/debux?tab=readme-ov-file#debugging-the-thread-macro-or.

p-himik 2025-09-15T11:46:04.292169Z

Also, writing a macro that works like -> or ->> but adds a debugging tap>/`prn` line in between each step is very easy and a nice macros-writing exercise if you feel like it.

2025-09-15T11:46:04.990059Z

Aha, debux that's the one. Thank you!

2025-09-15T11:46:38.826189Z

Will follow your advice on macro exercise)

p-himik 2025-09-15T11:48:22.686289Z

Just a tiny hint - I'd make that macro itself emit code that uses ->. No need to repeat work that -> already does for you.

👍 1
2025-09-15T13:13:16.681149Z

@yaro there is also https://www.flow-storm.org/, which will allow you to see that and much more

2025-09-15T13:15:07.478969Z

I have been meaning to have a look at it for ages now, but I really hate to get out of nvim

practicalli-johnny 2025-09-15T14:03:36.098379Z

I comment #_ out the expressions in the code that I don't want to include in the result https://youtu.be/XM8ymzlHRdQ?si=AidR26wVgo4H3Cs1 Or Emacs cider debug tool will step through an expression, form by form, showing the current values. Its a very good tool, especially for recursive code https://www.youtube.com/live/pyIbP4BOGpQ?si=MnmfdYChxQp75bMd&t=1145

2025-09-15T12:25:24.287619Z

Hi everyone! I know that when we transform strings into symbols (for example (symbol "+")) the generated symbol is not bound to the + function of the core lib. However. If I ran the following, the result is 1, what is the reason for this behavior? I ran some tests, and looks like the call is always returning the last number in the function call. ((symbol "+") 1 1)

p-himik 2025-09-15T12:36:27.644639Z

Symbols as objects are invokable and work in the same exact way as keywords - they look themselves up in an associative data structure.

user=> (def m {'a 1})
#'user/m
user=> ((symbol "a") m)
1
In your example, something like the [map key not-found] arity of get is used, so the first 1 is map, the symbol itself is key, and the second 1 is not-found. 1 is not associative, it can have no keys, so the not-found value is returned:
user=> ((symbol "+") 1 :not-found)
:not-found

2
2025-09-15T12:46:53.243329Z

So, in my snippet, it is "searching" for the symbol + inside the first 1, and since it is not found, it returns the second 1, am I correct?

p-himik 2025-09-15T12:47:39.814969Z

Yep!

2025-09-15T13:09:30.019099Z

Thank you for the information!

2025-09-15T13:32:11.732049Z

Is there any map containing all functions of the core lib?

p-himik 2025-09-15T13:35:15.856999Z

Of course, (ns-publics 'clojure.core).

🎉 1
2025-09-15T14:08:44.091429Z

In case you're asking about the map of functions because you're trying to bind the symbol from a string to the actual function, take a look at resolve or ns-resolve

👀 1
p-himik 2025-09-15T15:24:30.631719Z

Oh, and in that case - requiring-resolve. Because ns-resolve won't work when the target ns isn't loaded.

➕ 1