Wow--thanks very much for looking at the code, Tassilo. Ah, yeah, the problem is that you still need to extend the existing > SimState class and thus you need gen-class. In case SimState is a > non-abstract class and also comes with an interface ISimState, you could > probably get rid of gen-class by having a deftype which wraps a SimState > object and just delegates the ISimState methods to that. >
It's not abstract, but there's not an interface. In theory, maybe I could use reify or even proxy to subclass SimState, I think, if I didn't need to type hint variables holding the subclass. Not sure. I can store the state in an atom using a closure over the class object. I'm not sure whether I can make a static main() method. There might be other problems. Not clear that it would be worth the trouble. > And I think you could get rid of your gen-interface, too. AFAICS, the > only reason you use it is that you extend some existing interface by > adding one method. Yes. In the future there might be more methods, but I don't think that would matter. > This method could also be declared by some > ExtendedSteppable protocol, and then your deftypes define impls for the > Steppable interface and the ExtendedSteppable protocol. > Ah, thanks. I tried that, and it works, and is the same speed--maybe even slightly faster. > Not saying that this would make a big difference. But I'd try to avoid > the gen-* functions. IMHO, if you really need to use them (and some > Why would it be undesirable to use gen-interface? The syntax is pretty simple, and defprotocol and definterface both expand to a gen-interface expression. I admit it feels more idiomatic use defprotocol with the strategy that you suggested. > Java libraries can force you to), then you could just write these > classes in plain Java. I mean, gen-* stuff will most probably be quite > imperative, non-idiomatic Clojure code anyway, so just use Java for that > and then use these classes from Clojure. Mixed Java/Clojure projects > are really well-supported with Leiningen, no need to screw a nail with a > screwdriver (Clojure) when you have a hammer (Java). > I guess my goal here has been to see how hard it was to use a screwdriver. MASON programs are often pretty small, so if I'm going to replace a piece of a program with Java, I might as well just use Java throughout--but I don't really want to do a lot of Java programming. I also use NetLogo for agent-based simulations. It's somewhat Lisp-ey, and very easy, though not particularly fast. If my choice is between MASON with Java and NetLogo, I'd probably use NetLogo, unless I really need speed badly. Just personal preference. Thanks- Marshall -- 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 --- 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.