Ah, the array was a trick I used in java code : because I want to get a
value from another thread, the reference passed to the Runnable must be
final, and the Runnable can't change it, but it can "act on it". So I could
also have created a little class with a field, and the Runnable would have
changed the field value. The array was just an easy and cheap
"out-of-the-box" "class" to be used for this purpose.

I haven't tried with something simpler that the array-like method, I suspect
it won't work in clojure, too. And I didn't want to use clojure's mutable
methods because :
- we already are in an IO operation, the mutation is local to the operation
- I don't want agents, because I don't want asynchronous behaviour
- I don't want refs, because I don't have to coordinate access on several
places by several threads
- I don't want atoms, because I also don't have to serialize access to a
single place by several threads

I'm yet not very used to think about thread concurrency and the associated
drawbacks, so my reasoning above may still have flaws.

Please, gurus in this area, if you can tell whether I'm correct or wrong,
and whether there is a more "clojurish" version to do this, please tell,

-- 
Laurent

2009/2/20 Berlin Brown <berlin.br...@gmail.com>

>
>
>
> On Feb 19, 6:24 pm, Laurent PETIT <laurent.pe...@gmail.com> wrote:
> > Yes, thank you, I did the simplification.
> >
> > I couldn't resist continue to do some work around the problem, and I
> finally
> > got both a working version of :
> >
> > swt-wrapper/sync-exec : a (debugged) macro that does what the initial
> thread
> > was about
> > swt-wrapper/swt-app : a macro to be called from the -main method of a
> > generated class (that will be the main class of the SWT app) and that
> > encapsulates the main readDispatch loop.
> >
> > All this made available under the EPL license here :
> http://groups.google.com/group/clojure/web/swt_wrapper.clj
> >
> > HTH,
> >
> > --
> > Laurent
> >
> > 2009/2/19 Stephen C. Gilardi <squee...@mac.com>
> >
> >
> >
> > > On Feb 19, 2009, at 1:10 PM, Laurent PETIT wrote:
> >
> > >  Interesting, but is that an implementation detail, or an exposed
> feature ?
> >
> > > It's documented at:
> >
> > >http://clojure.org/special_forms#fn
> >
> > > (at the bottom)
> >
> > > --Steve
>
> Good code Laurent.  What was the purpose of the array though?
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to