Hi Mike, This is interesting, thanks for writing it. I understand Refs better than Agents, but even so, I'm thinking I was wrong when I first suggested using Agents for Cells.
Pondering aloud here: The critical property of a Cell is that it is completely finished updating before any of its dependent ("child") cells are updated. Does this property still hold when using Agents instead of Refs? I'm not sure it does, since an action on an Agent occurs at an unspecified time in the future. In the first examples I wrote, it probably doesn't matter. Here's a more stressful example: (def first-cell (cell 1)) (trace-cell first-cell) (def bunch-of-cells (doall (take 5000 (iterate (fn [previous] (cell (inc (cv previous)))) first-cell)))) (def last-cell (cell (inc (cv (last bunch-of-cells))))) (trace-cell last-cell) This works using cells.clj: user=> (alter-cell first-cell 2) first-cell changed from 1 to 2 last-cell changed from 5001 to 5002 But using acells.clj, you get an "Exception: Agent has errors" on (def bunch-of-cells ...). The stack trace ends in a NullPointerException, I think because new Cells are trying to dereference Cells that have not yet been initialized. This is not to say definitively that Agents won't work for Cells -- just that they may require more protections. Incidentally, even with Refs, bunch-of-cells can't be much longer than 5000 without causing a StackOverflow. But I'm guessing a 5000+ chain of serial dependencies is pretty rare. -Stuart On Sep 21, 7:29 pm, MikeM <[EMAIL PROTECTED]> wrote: > Thanks for doing this. I've been curious about cells for a while, and > wondered how it could be done in Clojure. > > Your comment (in the other thread) about using agents inspired me to > see how this would work. I've uploaded acells.clj to the group, which > is my attempt at converting your cells implementation to use agents in > place of refs. Your examples work, but I haven't done anything with it > beyond this. I'd like to hear your comments. --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---