Re: Cells in Clojure

2008-09-23 Thread Stuart Sierra
On Sep 23, 11:11 am, Rich Hickey <[EMAIL PROTECTED]> wrote: > On Sep 23, 10:47 am, Stuart Sierra <[EMAIL PROTECTED]> > wrote: > > Cool, thanks Rich!  This will be fun to play with.  One question -- is > > it possible to get the previous value of the agent (before the action) > > from within the ca

Re: Cells in Clojure

2008-09-23 Thread Rich Hickey
On Sep 23, 11:11 am, Rich Hickey <[EMAIL PROTECTED]> wrote: > On Sep 23, 10:47 am, Stuart Sierra <[EMAIL PROTECTED]> > wrote: > > > On Sep 23, 9:50 am, Rich Hickey <[EMAIL PROTECTED]> wrote: > > > > I've added some support for agent watches. You should consider it > > > experimental, but it will

Re: Cells in Clojure

2008-09-23 Thread Rich Hickey
On Sep 23, 10:47 am, Stuart Sierra <[EMAIL PROTECTED]> wrote: > On Sep 23, 9:50 am, Rich Hickey <[EMAIL PROTECTED]> wrote: > > > I've added some support for agent watches. You should consider it > > experimental, but it will allow the creation of cell-like and other > > reactive systems. > > Coo

Re: Cells in Clojure

2008-09-23 Thread Rich Hickey
On Sep 23, 10:47 am, Stuart Sierra <[EMAIL PROTECTED]> wrote: > On Sep 23, 9:50 am, Rich Hickey <[EMAIL PROTECTED]> wrote: > > > I've added some support for agent watches. You should consider it > > experimental, but it will allow the creation of cell-like and other > > reactive systems. > > Coo

Re: Cells in Clojure

2008-09-23 Thread Stuart Sierra
On Sep 23, 9:50 am, Rich Hickey <[EMAIL PROTECTED]> wrote: > I've added some support for agent watches. You should consider it > experimental, but it will allow the creation of cell-like and other > reactive systems. Cool, thanks Rich! This will be fun to play with. One question -- is it possib

Re: Cells in Clojure

2008-09-23 Thread Stuart Sierra
Hi mac, On Sep 23, 6:42 am, mac <[EMAIL PROTECTED]> wrote: > Does this not mean that if several alter-cell statements execute in > parallell on the same cell then it is possible that some of the > functions set in the first send are discarded? I *think* this shouldn't matter, because only the *l

Re: Cells in Clojure

2008-09-23 Thread Rich Hickey
On Sep 22, 10:55 pm, "Stuart Sierra" <[EMAIL PROTECTED]> wrote: > Ok, here's another version of Cells, attached. This one uses Agents, > like MikeM wrote. It works even on a 1-link chain of dependencies > -- see examples in the comment at the end. Cells get updated > asynchronously via ac

Re: Cells in Clojure

2008-09-23 Thread mac
I just started looking at this today, I think it looks very cool. Can't say I completely understand the code yet because I just read through it rather quickly. But I have a question about the alter-cell function in the last version posted by Stuart: The last two lines of alter-cell are sends to th

Re: Cells in Clojure

2008-09-22 Thread Stuart Sierra
Ok, here's another version of Cells, attached. This one uses Agents, like MikeM wrote. It works even on a 1-link chain of dependencies -- see examples in the comment at the end. Cells get updated asynchronously via actions on Agents. I may be missing some (dosync ...) wrappers in there. I

Re: Cells in Clojure

2008-09-22 Thread Rich Hickey
> > I've often thought of providing change notification queues on the > > agents themselves, letting Clojure do reactive programming right out > > of the box. > > This sounds like a powerful capability to have, if only to be able to > trace agent changes easily for debugging and monitoring. Would

Re: Cells in Clojure

2008-09-22 Thread MikeM
> "If during the function execution any other dispatches are made > (directly or indirectly), they will be held until after the state of > the Agent has been changed." > > That means that if, as a result of an update, some agent sends > messages to others, they will definitely arrive after the or

Re: Cells in Clojure

2008-09-22 Thread Rich Hickey
On Sep 22, 12:07 pm, MikeM <[EMAIL PROTECTED]> wrote: > > On second thought, maybe Agents will work, if one can enforce the > > ordering of updates. > > "Actions dispatched to an agent from another single agent or thread > will occur in the order they were sent" (from clojure.org/agents) - > see

Re: Cells in Clojure

2008-09-22 Thread MikeM
> On second thought, maybe Agents will work, if one can enforce the > ordering of updates.   "Actions dispatched to an agent from another single agent or thread will occur in the order they were sent" (from clojure.org/agents) - seems like this may be helpful, but since updates can occur from mu

Re: Cells in Clojure

2008-09-22 Thread Stuart Sierra
On Sep 21, 11:45 pm, Stuart Sierra <[EMAIL PROTECTED]> wrote: > 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 no

Re: Cells in Clojure

2008-09-21 Thread Stuart Sierra
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 depe

Re: Cells in Clojure

2008-09-21 Thread MikeM
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 impleme

Re: Cells in Clojure

2008-09-21 Thread Stuart Sierra
On Sep 21, 8:08 am, Albert Cardona <[EMAIL PROTECTED]> wrote: > clojure.lang.Compiler$CompilerException: cells.clj:35: Unable to resolve > symbol: sequential? in this context > > What am I missing? I have latest svn clojure. Hi Albert, I'm not sure. I can't reproduce this on Clojure SVN rev. 103

Re: Cells in Clojure

2008-09-21 Thread Albert Cardona
Stuart, > I've attached a trivial implementation of Cells in Clojure. It's not > as fancy as the original CL version, but I think it gets the idea > across. > clojure.lang.Compiler$CompilerException: cells.clj:35: Unable to resolve symbol: sequential? in this context What am I missing?

Re: Cells in Clojure

2008-09-20 Thread Stuart Sierra
Exactly. Here's some demo code, attached, that uses a cell in a JPanel. This is a simple example, but maybe it shows how this could be useful when you have many objects with complex dependencies. -Stuart On Sep 20, 7:54 pm, kyle smith <[EMAIL PROTECTED]> wrote: > Maybe you could attach a cell to

Re: Cells in Clojure

2008-09-20 Thread kyle smith
Maybe you could attach a cell to a JComponent and call setEnabled as necessary. --~--~-~--~~~---~--~~ 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 unsubsc