I have a project in which I have to use some java mutable objects
(e.g. a graph).
In my code, I have some functions that get these objects and add nodes
to them, for instance:
(defn make-graph [] .... returns a graph wrapped with other things)
(defn add-to-graph [graph n] .... adds n to the structure ...)
In order to use the threading macro -> I have done that all functions
returns the mutated graph, so I can write:
(def my-graph (-> (make-graph)
(add-to-graph 1 2 3)
(add-to-graph 4 5 6)
....))
But as convenient as this is, I think its misleading and inelegant
because -> is a functional threading. I feel I need some king of doto
but fir clojure code. Something like:
(def my-graph (make-graph))
(doto mygraph
(add-to-graph! 1 2 3)
(add-to-graph! 4 5 6))
Is this a valid concern or I am overzealous over this?
Thanks.
Juan Manuel
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en