Mars0i <marsh...@logical.net> writes: > MASON simulations typically consist of > > (a) One or more "agents", which implement an interface (Steppable) > with a single method, step(). > > (b) An instance of a class that extends SimState, which contains a > scheduler that repeatedly calls step() in every agent that's registered > with it. > > The agents have to interact with each other, and the way that they > find out about each others' states is typically through the the > SimState object that's automatically passed to step(). The point is > that the only way for teach Student to know about other instances of > Students is by knowing about an object that also has to know about > Students. There's the cycle. > > [snip] > > I use gen-class in order to implement Steppable and to extend > SimState. The type hint that I delete and restore is for the second > argument to the step() function required by Steppable: > > (defn -step [^students.Student this ^students.StudentsSimState sim-state]
Since Steppable is an interface, you could define Student using `deftype` or `defrecord` instead of `gen-class`. Then you can call (step my-student sim-state) without type hint which should be equally fast as (.step ^Student my-student ^StudentSimState sim-state). And instead of having one SimState-extending class per kind of agent, you could have just one class `SimStateImpl` which has as a field `attrs` which is a map. In that map, you could put stuff specific to Students or stuff specific to Teachers (or whatever kinds of agents you have). Then, the only point where you might need a type hint is where you access the `attrs` map. But here, the type is always `SimStateImpl`. Alternatively, you could also define a protocol for accessing the `attrs` map, or many protocols if it's better for you to have many SimState-extending classes. Bye, Tassilo -- 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.