On Thu, Mar 31, 2016 at 11:56 AM, Timothy Baldridge <tbaldri...@gmail.com> wrote:
> But we should mention that recursive data structures that contain refs are > a bit of a code-smell. Your structures are no longer immutable if they > contain refs which are mutable containers for immutable data. Something to > think about. > I understand, but this library is all about state because it is about modelling long-lived entities over time as an unpredictable stream of events act on the model. One good use case was a virtual RoboCup soccer team fed sensory data every 100ms and responding with actions such as turning, moving, and kicking. So we have a long-lived soccer player instance who observes the world, forms a strategy consisting of so many tactics and emits actions based on the current tactic. New information comes in and the tactic itself has a condition that says when it has succeeded or should be abandoned. etc etc. This is modeled with a player instance (or "model") and slots for strategy etc, each of which is a ruled cell working off the sensory data. These Cells depend on each other and notify their dependents when they change. Here comes the cycle: a Cell knows the model and slot-name it is mediating, so it is self sufficient: if someone tells me to recompute, I can do so without also being told the instance. I can then also invoke any observers, which are dispatched by slot name. Well, this much I can change: when someone asks for my value I just need to record two pieces of information, the model and slot-name. Of course my next problem is that no model is an island: they exist in trees where each node knows its parent (whassat? a DAG?). Hello cycle. Well, I guess just recording the model did that. Anyway, the solution that springs to mind is keeping one big dictionary keyed off a serial integer. Thank god for 64-bits. :) Thx, kt > On Thu, Mar 31, 2016 at 9:53 AM, James Reeves <ja...@booleanknot.com> > wrote: > >> On 31 March 2016 at 16:39, hiskennyness <kentil...@gmail.com> wrote: >> >>> In porting my modelling library Cells to Clojure I managed to get a >>> stack overflow when the printer tried to print a recursive data structure* >>> I have used in the Common Lisp version. >>> >>> * Basically, a ref holds a map in which some values are maps in which >>> some values are the ref. >>> >>> In Lisp we have *print-depth* as well as *print-length* to deal with >>> just this case. >>> >>> Is there some way I can deal with this, or are recursive data structures >>> not really supported by Clojure? >>> >> >> The same variables exist in Clojure: *print-level* and *print-length* >> respectively. >> >> - James >> >> -- >> 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. >> > > > > -- > “One of the main causes of the fall of the Roman Empire was that–lacking > zero–they had no way to indicate successful termination of their C > programs.” > (Robert Firth) > > -- > 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 a topic in the > Google Groups "Clojure" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/clojure/TGtavJVzVWk/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Kenneth Tilton Founder/Developer TiltonTec 54 Isle of Venice Dr Fort Lauderdale, FL 33301 k...@tiltontec.com http://tiltontec.com @tiltonsalgebra 646-269-1077 "In a class by itself." *-Macworld* -- 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.