Re: Listen on changes to refs

2008-12-20 Thread Christian Vest Hansen
On Sat, Dec 20, 2008 at 3:49 AM, Rowdy Rednose wrote: > > Validators seem like an easy way to do it, I'll try that. Thanks > Chouser! Just a caution. Validators can run even if the ref does not change. For instance when a transaction is aborted by another validator. > > Afaik Rich only thinks a

Re: Listen on changes to refs

2008-12-19 Thread Rowdy Rednose
Validators seem like an easy way to do it, I'll try that. Thanks Chouser! Afaik Rich only thinks about adding watchers to refs currently, and I can't find it in the list: http://code.google.com/p/clojure/issues/list?can=2&q=&colspec=ID+Type+Status+Priority+Reporter+Owner+Summary&cells=tiles So i

Re: Listen on changes to refs

2008-12-19 Thread Rowdy Rednose
To give some structure to my previous questions - How would I make refs, that I'm interested in, send an agent on every change, without having to do that manually? A: Extend the Ref class (either in Clojure land or in Java land) B: overload/overwrite (however that would be achieved in Clojure) th

Re: Listen on changes to refs

2008-12-19 Thread Chouser
On Fri, Dec 19, 2008 at 8:35 PM, Rowdy Rednose wrote: > > Apart from being blasphemous - would it be a good idea to override > clojure.lang.Ref in Java land? > > I want to create (children of?) refs in clojure that send an agent > when they change, so that I can create facilities to observe chang

Re: Listen on changes to refs

2008-12-19 Thread Rowdy Rednose
Apart from being blasphemous - would it be a good idea to override clojure.lang.Ref in Java land? I want to create (children of?) refs in clojure that send an agent when they change, so that I can create facilities to observe changes to them. Creating a 'MyRef extends Ref' seems to be the obvious

Re: Listen on changes to refs

2008-12-17 Thread Chouser
On Wed, Dec 17, 2008 at 7:26 AM, Rowdy Rednose wrote: > > Now before I start working on a small and handy framework to handle > stuff similar to what's called biz objects / biz models in the java > world - has by any chance someone already implemented something in > that direction? It's not a fr

Re: Listen on changes to refs

2008-12-17 Thread Rowdy Rednose
That's great news. Thanks Dave! Re-reading http://clojure.org/agents I found it mentioned somewhere at the end, almost like a small, unimportant footnote, easy to overlook... Now before I start working on a small and handy framework to handle stuff similar to what's called biz objects / biz mode

Re: Listen on changes to refs

2008-12-17 Thread Dave Griffith
> I'm actually trying to get a notification after a transaction > successfully finished. Well that's easy. Agent sends are buffered in a transaction, and only sent upon successful commit. The coolness of this is hard to overestimate. --Dave Griffith --~--~-~--~~~--

Re: Listen on changes to refs

2008-12-17 Thread Rich Hickey
On Dec 17, 2008, at 4:16 AM, Rowdy Rednose wrote: > > If Rich adds watchers for refs, would watchers be notified inside the > transaction? No, only on commit. Rich > > > I'm actually trying to get a notification after a transaction > successfully finished. Although there might be use cases f

Re: Listen on changes to refs

2008-12-17 Thread Rowdy Rednose
If Rich adds watchers for refs, would watchers be notified inside the transaction? I'm actually trying to get a notification after a transaction successfully finished. Although there might be use cases for firing events inside the transaction. On 17 Dez., 00:37, Stuart Sierra wrote: > On Dec 16

Re: Listen on changes to refs

2008-12-17 Thread Rowdy Rednose
The structure of the wikibook page has changed and that link doesn't work any more. This will: http://en.wikibooks.org/wiki/Clojure_Programming/Concepts#Mutation_Facilities On 16 Dez., 20:58, Rowdy Rednose wrote: > Can I listen on changes done to refs? > > Let's say in a scenario like that > o

Re: Listen on changes to refs

2008-12-16 Thread Stuart Sierra
On Dec 16, 7:50 am, Timothy Pratley wrote: > SS wrote a cells that works on refs quite a while > ago:http://groups.google.com/group/clojure/browse_thread/thread/d79392e4c... Yeah, it works, but the interface is a little awkward. Rich said he wants to add watchers for refs and atoms in addition

Re: Listen on changes to refs

2008-12-16 Thread Timothy Pratley
SS wrote a cells that works on refs quite a while ago: http://groups.google.com/group/clojure/browse_thread/thread/d79392e4c79f8cde/f92eae422e4086c5?lnk=gst&q=cells+refs#f92eae422e4086c5 If you search the group for "cells" you'll find quite a bit of discussion --~--~-~--~~

Re: Listen on changes to refs

2008-12-16 Thread Rowdy Rednose
There must be a smarter way to achieve this than polling the collection for changes, I guess. On 16 Dez., 21:43, Dave Griffith wrote: > Right now, you add listeners to agents, but not refs. IIRC, there > was talk of adding listeners to refs to enable just the sort of > reactive programming you

Re: Listen on changes to refs

2008-12-16 Thread Dave Griffith
Right now, you add listeners to agents, but not refs. IIRC, there was talk of adding listeners to refs to enable just the sort of reactive programming you describe, but I don't know the status. --~--~-~--~~~---~--~~ You received this message because you are subsc

Listen on changes to refs

2008-12-16 Thread Rowdy Rednose
Can I listen on changes done to refs? Let's say in a scenario like that on http://en.wikibooks.org/wiki/Clojure_Programming#Mutation_Facilities could I add a facility that allows the registration of listeners that get called on certain changes to the refs? For example I'd like to be notified on