Cells using agents and watchers

15 views
Skip to first unread message

Stuart Sierra

unread,
Jan 29, 2009, 9:43:24 PM1/29/09
to Clojure
Hi everyone,

I have put together a another implementation of Cells. This one uses
agents and watchers, so it's asynchronous, unlike the original Cells
for Common Lisp. I've called it "auto-agents". It's in
clojure.contrib.auto-agent.

The idea is the same as Cells. You create a special variable (an "auto-
agent") whose value is defined by an expression. Whenever one of the
other variables (agent, atom, or ref) referenced in the expression
changes its value, the expression is automatically reevaluated and the
value of the auto-agent is updated.

-Stuart Sierra

Timothy Pratley

unread,
Jan 30, 2009, 8:53:34 AM1/30/09
to Clojure
Hi Stuart,

On Jan 30, 1:43 pm, Stuart Sierra <the.stuart.sie...@gmail.com> wrote:
> I have put together a another implementation of Cells.

Cool!

One of the things I really like about Cells is that it can really take
the pain out of MVC style GUI building:
http://github.com/timothypratley/strive/blob/8285ef1419601411797205de0d60a2b2c0b71be0/src/clj/cells.clj
should demonstrate better than I can articulate.
To me that's an exciting aspect of cells, but also difficult to cover:
watching-label is quite useful, but people might wish to use a wider
range of controls which would need similar helpers. I'd be interested
in your thoughts on the matter, and whether you think there is scope
to include watching-label and/or similar.


> The idea is the same as Cells. You create a special variable (an "auto-
> agent") whose value is defined by an expression. Whenever one of the
> other variables (agent, atom, or ref) referenced in the expression
> changes its value, the expression is automatically reevaluated and the
> value of the auto-agent is updated.

Nice code - very useful.


Regards,
Tim.

Stuart Sierra

unread,
Jan 30, 2009, 10:29:09 AM1/30/09
to Clojure
Thanks, Tim, glad you like it. I agree one of the most interesting
uses for Cells is GUI programming. I'd love to see a library for
building Swing GUIs this way, although I would want to keep the GUI
functions separate from the cell library itself.

From the libraries thread, I can see that there are at least two other
implementations of Cell-like libraries, so clearly there's a lot of
interest in this topic.

-Stuart Sierra


On Jan 30, 8:53 am, Timothy Pratley <timothyprat...@gmail.com> wrote:
> Hi Stuart,
>
> On Jan 30, 1:43 pm, Stuart Sierra <the.stuart.sie...@gmail.com> wrote:
>
> > I have put together a another implementation of Cells.
>
> Cool!
>
> One of the things I really like about Cells is that it can really take
> the pain out of MVC style GUI building:http://github.com/timothypratley/strive/blob/8285ef1419601411797205de...
Reply all
Reply to author
Forward
0 new messages