Hey @alandipert,
If I want my deftype to be handled by hoplon elements as a map {} or vec [] what do I need to do?
Sorry if it's a big question, I'm digging inside hoplon.core myself I was just wondering if you already have the answer
I believe the answer is here somewhere:
(defn parse-args
"Parses a sequence of element arguments into attributes and children."
[args]
(loop [attr (transient {})
kids (transient [])
[arg & args] args]
(if-not (or arg args)
[(persistent! attr) (persistent! kids)]
(cond (map? arg) (recur (reduce-kv assoc! attr arg) kids args)
(set? arg) (recur (reduce #(assoc! %1 %2 true) attr arg) kids args)
(attribute? arg) (recur (assoc! attr arg (first args)) kids (rest args))
(seq? arg) (recur attr (reduce conj! kids (vflatten arg)) args)
(vector? arg) (recur attr (reduce conj! kids (vflatten arg)) args)
:else (recur attr (conj! kids arg) args)))))Hm looks like seq? is the most general test there that does splicing
Thank you 🙏 I've managed something
Awesome, look forward to hear about it. Saw you mention AMOP elsewhere, big CLOS fan myself. Would love it in clj/s