Hello,
I’ve reading about the Self language, and got experimenting with multi-methods to mimick Self-style messages. I was curious what folks think about this pattern:
(ns self)
(def path "./hello.txt")
(defn inst [msg]
(if (map? msg) (keys msg) msg)
)
(defmulti hello inst)
(defmethod hello [:save] [msg]
(spit path (msg :save))
)
(defmethod hello :load [msg]
(slurp path)
)
(defn do-run [h]
(h {:save "world"})
(println (h :load))
)
(defn run [opts]
(do-run hello)
)
Do you find this pattern interesting, useful? The example doesn’t show it, but there could be messages with multiple keywords.
Thanks,
- Quenio