News for hackers. Stuff that matters.
Re:Push ifs up and fors down by runeks on Thursday November 16, 2023 @03:12AM (#38286922)
> As an example I work with - Clojure. Sometimes I use agents. I don't write functions for agents, I write functions for things agents might contain.

I'm not following you. Do you have a better example?

Re:Push ifs up and fors down by bcrosby95 on Thursday November 16, 2023 @11:21AM (#38291465)
Similar to the example of the OP:

  (def walrus (agent {}))

  ; good
  (defn frobnicate [w]
    (assoc w :frobnicated true))
  (send walrus frobnicate)

  ; bad
  (defn frobnicate [w]
    (send walrus #(assoc % :frobnicated true)))
  (frobnicate walrus)
It might make sense to also have a function that executes something like (send walrus frobnicate). But IMHO code should basically never look like the bad example.