On Fri, Jun 7, 2013 at 9:28 PM, Gary Trakhman <[email protected]>wrote:
> sounds fun, have you seen this yet? > > > http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/ > wicked cool thx I'll do this then : (deftype Foo [^{:volatile-mutable true} x] Object (setBar [this s] (set! x (do-some-stuff))) (baz [this ] x)) Oh boy! My first attempt was ugly :) > > > > On Fri, Jun 7, 2013 at 3:21 PM, Denis Labaye <[email protected]>wrote: > >> Hi, >> >> I'm writting Clojure code that is used by a Java framework (Fitnesse's >> slim for those who knows). >> >> To workflow is like this: >> Instanciation of a new Java objectf = new Foo()Initialization with >> setters f.setBar("ze bar")And then call some methods f.baz() >> >> My solution is something like: >> >> (ns Foo >> (:gen-class >> :methods [[setBar [String] void ] >> [baz [ ] String ]])) >> >> (def results (atom {})) >> >> (defn -setBar [this s] (swap! results assoc this (do-some-stuff)) >> (defn -baz [this ] (@results this)) >> >> It works but is ugly. (Memory is not a problem so no need to release the >> objects/results map entries in the atom). >> >> Is this okay ? Can we do better ? >> >> Thx >> >> Denis >> >> -- >> -- >> 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 >> --- >> You received this message because you are subscribed to the Google Groups >> "Clojure" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- > -- > 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 > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
