 
 ;;; Transient local memory implementation. Typically only persistent memory will be visible externally.
 
-;;; Internal helper macro to manage our transient memory.
-;;; We must update the content on each call to correctly use the underlying transient map.
-(defmacro assoc-mem! [k v]
-  `(set! ~'content (assoc! ~'content ~k ~v)))
-
 (deftype TransientLocalMemory [rulebase ^:unsynchronized-mutable content]
   IMemoryReader
   (get-rulebase [memory] rulebase)

  (add-elements! [memory node join-bindings elements]
    (let [key [:alpha-memory (:id node) join-bindings]
          current-facts (get content key [])]
      (assoc-mem! key (concat current-facts elements)) ))

  (remove-elements! [memory node join-bindings elements]
    (let [key [:alpha-memory (:id node) join-bindings]

          filtered-facts (remove-first-of-each element-set current-facts)]

      ;; Update the memory with the changed facts.
      (set! content (assoc! content key filtered-facts))

      ;; return the removed elements.
      (s/intersection element-set (set current-facts))))
