Fork me on GitHub

@peter.kehl Not sure what you're asking -- lots of macros out there inject def into the namespace in which they are invoked.


deftest in clojure.test, for example. Even defmacro itself injects a def.


Thanks @seancorfield. In my macro, I was generating code that used clojure.core/def instead of def. I didn't know that special forms are namespace-less.


After all, they are special.


Sorry, the semantics are values. I did not add the full structure:

{:column-name {1 5 55 68 8 47}}
Example: when column-name has a value of 1 update it to 5 and so on


well, a classic way of doing polymorphism in Clojure is to use multi-methods


so you could define a multi-method that dispatches to discern which row type you have and then from there, return a map of values you want to update:

(defmulti update-map (fn [row] <discern row type>))

(defmethod update-map :type-one
  {:column-name {1 5 55 68 8 47}})


if you need something more dynamic, like you’re programmatically creating these update maps, then you could use something like:

(defn update-map [row updaters]
  (let [row-type <discern row-type>]
    (get updates row-type)))

(update-map row {:type-one {:column-name {1 5 55 68 8 47}}})

👍 5

Hi team. Can a macro somehow detect whether the user's namespace has def-ined a variable with a given name? (Something like &env, but for def?)


I'll try with ns-resolve.


"State of Clojure 2019" survey ( has a #19 question: "Rate the priority of making improvements to Clojure in these areas." > "AOT". What does AOT mean?


Ah, "Ahead of Time" compilation

👌 5

recursion is still a hard concept for me to grasp sometimes. I try and write out the steps on paper but sometimes it gets a little crazy. is there a way for the repl to step through the function for me? Is that what debugging is? I think I remember Racket had something like that in their DrRacket IDE and it was helpful.

Lennart Buit19:01:59

Cursive has the ability to step through code step by step.

Lennart Buit19:01:06

That said, as cheesy as it sounds, you have to believe in recursion. “If I do this now, and recur, and end then, I have my problem solved”.

Lennart Buit19:01:47

I would recommend just looking at some recursive algorithms, fibonacci comes to mind and quicksort/mergesort

Lennart Buit19:01:21

Its just something that clicks eventually, so to say


That actually makes sense to me. I was prompted to ask when I realized I knew what a 4clojure recursion exercise was going to return but had difficulty doing the step by step of it after the fact.


I'm using Cider and apparently it does have the capability if I do want to explore it. Thanks for the chat

Lennart Buit21:01:05

(We have the same generated avatar, annoying) You’re welcome

👍 5

is that def creates var?


Hi team. Is metadata supposed/planned to work with symbols? says so. However, while the following doesn't fail, it doesn't carry any meta either: (meta ^:hello 'a) ;=> nil


'a => (quote a)


so you are putting metadata on the list that contains the quoted data, not the data


(with-meta 'a {:hello true}) will do what you want, because it adds metadata after evaluation, so the quote is stripped


user=> (read-string "'a")
(quote a)
user=> (eval (read-string "'a"))