Fork me on GitHub
Fredrik Meyer12:12:17

Is there a way to make qualified keywords from a string? Iā€™m thinking of for example making ::a from the string "a". Is the only way to type out the whole namespace in (keyword "" some-string) ?


@hrmeyer What about:

user=> (defn qkw [s] (keyword (str (ns-name *ns*)) s))
user=> (qkw "a")

Fredrik Meyer12:12:51

I tried that, but when I called my function from core, I noticed that *ns* refers to the current namespace.


yes, *ns* refers to the current namespace. ::a also resolved in the current namespace.


could you give an example of what is the expectation when calling it with two separate namespace?

Fredrik Meyer13:12:03

I might be misunderstanding something šŸ™‚ I have a namespace/file myfile.clj where I define these keys, and do some operations on them. But I get a different result when I call this this function from core.clj.


when you call the function from core.clj it will use the value to which *ns* is bound at that moment, which is foo.core


what is unexpected about this, and what should be happening?


so the function is defined in namespace B but you are calling it from namespace A, but the namespace in the keyword should always be from B?

Fredrik Meyer13:12:52

Yes, that is what I want to achieve šŸ™‚


in B you could do the following:

(def current-ns-name (ns-name *ns*))
(defn qkw [s] (keyword (str current-ns-name) s))

Fredrik Meyer13:12:29

Thank you! That worked!

šŸ‘ 3

Is there a point cloud library or an open 3d alternative for clojure?

šŸ‘€ 3

what's the best way of having an atom a update when atoms b or c update? Is there something like merge-atom? Or should I use add-watch?


maybe you could just merge the state of the three atoms into one?


it's a good suggestion, but it would break encapsulation in my case; I'm now interested in the toy problem on how to merge them properly


or just refs, depends on the type of operation and level of safety you want


having all state in 1 atom is way easier šŸ™‚


ok y'all make good points, so, let give some more context on the original problem: I'm using reagent, and I have a function that takes some data as a prop. Inside that function, I want to manipulate a local copy, and sync outside my program when the local state has some properties


so, I would prefer not to put all the state in one atom because that mixes up local and global state


but I don't know how to write that I want the local state to be either a result of the user manipulation, or the change coming from the global var, whichever came last


so basically I'd like something like r/with-let [local (r/atom global)], but which continues to post update to the value


@meditans I'm pretty sure that's a react anti pattern.


@meditans it sounds like you might want to look at re-frame


I'd advise making it a fully controlled component.


in a re-frame subscription you could merge the component local and global state and then act on that


there's also the more low level reaction API for reagent and r/track, which could possibly offer a solution for this


yeah, you could also have a component which gets the merged state as props and merge that state in the parent


Also reagent.ratom/reaction seems relevant.


that's what I meant with reaction API yeah


I think I did something like this in re-find.web, lemme check


thanks! give me a minute to parse all this info; you're right that it could be a react antipattern, and in fact part of this is learning what the correct patterns are (I usually write FRP, in which this problem doesn't exist)

Calum Boal15:12:25

Hey, so i'm trying to identify the value of a parameter being passed to a function. Im using emacs with cider, however, when i run the function via the repl i'm only getting back the return value of the call, not the printed value. Anyone know how i can access this?

(defn- sign-request
  ([client req]
   (println req)
   (client req)
For example, i'm trying to identify the value of req


@cgboal521 This value is printed in your cider REPL buffer


@cgboal521 You could also capture the value and then inspect it. E.g. like this:

Calum Boal15:12:01

Hmm, wasn't showing up but may be doing the wrong kind of repl execute in emacs. Cheers, will check that link

Calum Boal15:12:05

Cheers will take a look