Hi all, Is it possible to have a structure nested within a structure in Clojure? Consider the following code:
(defstruct rect :height :width) (defstruct color-rect :color (struct rect)) (defn #^{:doc "Echoes the details of the rect passed to it"} echo-rect [r] (println (:color r)) (println (:height r)) (println (:width r))) (def first-rect (struct rect 1 2)) ;(def c-rect1 (struct color-rect 249 first-rect)) ;form 1 ;output "249 nil nil" (def c-rect1 (struct color-rect 249 1 2)) ;form 2 ;output "Too many arguments to struct constructor (echo-rect c-rect1) Of course this is a contrived example but there are cases where I want to break a large data structure into smaller substructures to make code easier to maintain. As the comments indicate if I do form 1 I get "249 nil nil" but if I do form 2 I get "Too many arguments to struct constructor". If I'm approaching this issue in the wrong way, please tell me what I should be doing. I did search this group but I failed to turn up anything that seemed helpful. -- Onorio Catenacci --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---