Fork me on GitHub
#beginners
<
2022-01-23
>
popeye17:01:48

what is the meaning of immutability in defrecord ? i am running below code and I can see that the value is changing in defrecord ,

(def p (atom 0))

(defprotocol protocol-1
  (service [this a b] ))

(defprotocol protocol-2
  (plugin [this]))

(defrecord record [desc id name version]
  protocol-1
  (service [this a b]
    (println id " "name " "a " " (reset! version 1)))
  protocol-2
  (plugin [this]
     (println desc)))

(println (. (->record"a" "b" "c" p) service "k" "j"))

Alex Miller (Clojure team)17:01:46

The record has an immutable reference to an atom, which is mutable

popeye17:01:36

How to test immutability in defrecord

Alex Miller (Clojure team)18:01:06

defrecords store fields in Java class final fields, which by definition can't be modified once set in the constructor

sova-soars-the-sora21:01:12

is there a channel for machine learning and/or neural nets?

dharrigan21:01:44

#data-science

dharrigan21:01:11

Very active community (although mostly on zulip). If you ask there, someone will point you in the right direction 🙂