Ah, sorry, perhaps I misunderstand you, but if you use multimethods (defmulti) in Clojure you do not need to "attach" methods to anything. The defmulti will allow you "dispatch-on-type" based on the key which is present in the map (e.g. if :delete is present or if :insert is present).
The nice thing about multimethods the lisp style is that they are additive, e.g. you do not have to change anything in your op structure. On Jun 15, 4:38 am, Matthew Phillips <mattp...@gmail.com> wrote: > On Jun 14, 12:05 pm, gaz jones <gareth.e.jo...@gmail.com> wrote: > > > if i was writing the java i would probably do a "tell dont ask" > > refactoring so that the operations had an applyTo method: > > > List<Item> items = initialItems (); > > > for (Op op : operations) > > { > > op.applyTo(items); > > > } > > > not sure what your op data structure is, but i would image you could > > translate that to the clojure code also -- is that reasonable? > > I think you're right that the above is a better OO design, but that > was really just a Java translation of the sort of think I'd like to do > in Clojure (minus the mutable list). > > The ops in this case have abstract meaning (they are [source target > delta] tuples describing list transformations), and attaching > "methods" to them (presumably as fn's) in this case would be weird I > think, as well as requiring a switch from tuples to maps or records. -- 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 Note that posts from new members are moderated - please be patient with your first post. 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