I'd also caution against attempting to use >! and <! deep inside a call
chain. Send and receive are side-effects. Any function that contains them
is impure. Keep IO at the edges, and your whole system will be much easier
to test.

Timothy


On Wed, Apr 9, 2014 at 6:07 AM, t x <txrev...@gmail.com> wrote:

> For the purposes of building a webos:
>
> Having yield + co-routines gives me cooperative multi-threading --
> which is basically all I need.
>
>
> The main difference between co-routines and go-routines. Is that for
> (go ... ) blocks, the <! and >! must be lexically embedded within the
> block; whereas with co-routines, the send/receive can be called in
> functions I call.
>
>
> On Wed, Apr 9, 2014 at 1:11 AM, Moritz Ulrich <mor...@tarn-vedra.de>
> wrote:
> > What on this page would solve your problem? I just see
> > Generators/Iterators, Array Comprehensions, lexical let and
> > destructuring assignment.
> >
> > On Wed, Apr 9, 2014 at 9:39 AM, t x <txrev...@gmail.com> wrote:
> >> I believe
> https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/1.7
> >> suffices.
> >>
> >> However, it's currently Firefox only and no Chrome.
> >>
> >> On Tue, Apr 8, 2014 at 8:51 PM, Timothy Baldridge <tbaldri...@gmail.com>
> wrote:
> >>> What is going to fulfill a promise? How will you know when a promise is
> >>> fulfilled. In a single threaded VM like JS you're stuck with callbacks.
> >>> Nothing short of full program transformation will give you any better
> >>> experience than core.async.
> >>>
> >>> A good way to look at it is this...if you do this in ClojureScript what
> >>> javascript is this supposed to execute?
> >>>
> >>> (deref (promise))
> >>>
> >>> The only way this can work is with a code transform like go. Perhaps
> someday
> >>> a new version of JS will arise that presents a different solution, but
> until
> >>> then core.async is the best you're going to get.
> >>>
> >>> Timothy
> >>>
> >>>
> >>> On Tue, Apr 8, 2014 at 3:11 PM, t x <txrev...@gmail.com> wrote:
> >>>>
> >>>> I'm guilty of the X-Y problem.
> >>>>
> >>>>
> >>>> I'm trying to, inside of CLJS, write a simple WebOS.
> >>>>
> >>>>
> >>>> So I want to simultaneously be able to run things like:
> >>>>   * a notepad app
> >>>>   * an IRC app
> >>>>   * a webRTC video chat app
> >>>>
> >>>>
> >>>> I have built each of these individual pieces in CLJS, -- but combining
> >>>> them / having them work well together in a clean, non-spaghetti way is
> >>>> harder than I thought.
> >>>>
> >>>>
> >>>>
> >>>> ### The main problems here I have are:
> >>>>
> >>>>   * multi-threading (run all three apps at once) and
> >>>>   * have is inter-"process" (in this case app) communication
> >>>>
> >>>>
> >>>> I'd also prefer to do this in a way where I write each app as if it's
> >>>> the only app running (i.e. no callback hell.)
> >>>>
> >>>>
> >>>> One possible approach is to make each app a "go-thread", but then I
> >>>> run into the issue of:
> >>>>
> >>>>   (go ... (>! ... ) (<! ... )) all forced into the same lexical
> function.
> >>>>
> >>>>
> >>>>
> >>>> I'm looking for alternatives to this. By using:
> >>>>
> >>>>   settimeout(func, 0); I should be able to fire off 3 threads
> >>>>
> >>>>   now, if I had something like promises, I can do inter-process
> >>>> communication
> >>>>
> >>>>
> >>>>
> >>>> I'm still working this through -- so if my thinking is sloppy /
> >>>> unclear, please point it out so I can make it clearer.
> >>>>
> >>>>
> >>>> Thanks!
> >>>>
> >>>> On Tue, Apr 8, 2014 at 2:05 PM, James Reeves <ja...@booleanknot.com>
> >>>> wrote:
> >>>> > What exactly are you trying to do? Could you describe the problem
> you're
> >>>> > trying to solve in more detail?
> >>>> >
> >>>> > - James
> >>>> >
> >>>> >
> >>>> > On 8 April 2014 22:02, t x <txrev...@gmail.com> wrote:
> >>>> >>
> >>>> >> I'd really like to avoid callbacks. :-)
> >>>> >>
> >>>> >> If cljs had promises, it would suffice. :-)
> >>>> >>
> >>>> >> On Tue, Apr 8, 2014 at 2:00 PM, Gary Trakhman <
> gary.trakh...@gmail.com>
> >>>> >> wrote:
> >>>> >> > I think you might be able to use put! with a callback, or (go (>!
> >>>> >> > ..))
> >>>> >> > within foo for a transient go process.  Not sure if there's any
> ill
> >>>> >> > effects.
> >>>> >> >
> >>>> >> >
> >>>> >> > On Tue, Apr 8, 2014 at 4:51 PM, t x <txrev...@gmail.com> wrote:
> >>>> >> >>
> >>>> >> >> Hi,
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>   * I am aware of core.async. However, I don't like the fact
> that
> >>>> >> >> (go
> >>>> >> >> ... ) is a macro, thus forcing the >! and <! to appear "in the
> >>>> >> >> body",
> >>>> >> >> and I can't do nested things like:
> >>>> >> >>
> >>>> >> >>   (defn foo [chan]
> >>>> >> >>      (let [x (<! chan)] ... ))
> >>>> >> >>
> >>>> >> >>   (go ... (foo ... ))
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>   * For the following, I only need it to work in ClojureScript.
> I
> >>>> >> >> don't need it to work in Clojure. Furthermore, we can assume
> browser
> >>>> >> >> =
> >>>> >> >> latest Firefox, or browser = latest Chrome.
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>   Now, my question: is there a library which provides "true"
> >>>> >> >> lightweight Clojurescript threads?
> >>>> >> >>
> >>>> >> >>
> >>>> >> >> Thanks!
> >>>> >> >>
> >>>> >> >> --
> >>>> >> >> 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
> >>>> >> >> Note that posts from new members are moderated - please be
> patient
> >>>> >> >> with
> >>>> >> >> your first post.
> >>>> >> >> 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
> >>>> >> >> ---
> >>>> >> >> You received this message because you are subscribed to the
> Google
> >>>> >> >> Groups
> >>>> >> >> "Clojure" group.
> >>>> >> >> To unsubscribe from this group and stop receiving emails from
> it,
> >>>> >> >> send
> >>>> >> >> an
> >>>> >> >> email to clojure+unsubscr...@googlegroups.com.
> >>>> >> >> For more options, visit https://groups.google.com/d/optout.
> >>>> >> >
> >>>> >> >
> >>>> >> > --
> >>>> >> > 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
> >>>> >> > Note that posts from new members are moderated - please be
> patient
> >>>> >> > with
> >>>> >> > your
> >>>> >> > first post.
> >>>> >> > 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
> >>>> >> > ---
> >>>> >> > You received this message because you are subscribed to the
> Google
> >>>> >> > Groups
> >>>> >> > "Clojure" group.
> >>>> >> > To unsubscribe from this group and stop receiving emails from it,
> >>>> >> > send
> >>>> >> > an
> >>>> >> > email to clojure+unsubscr...@googlegroups.com.
> >>>> >> > For more options, visit https://groups.google.com/d/optout.
> >>>> >>
> >>>> >> --
> >>>> >> 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
> >>>> >> Note that posts from new members are moderated - please be patient
> with
> >>>> >> your first post.
> >>>> >> 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
> >>>> >> ---
> >>>> >> You received this message because you are subscribed to the Google
> >>>> >> Groups
> >>>> >> "Clojure" group.
> >>>> >> To unsubscribe from this group and stop receiving emails from it,
> send
> >>>> >> an
> >>>> >> email to clojure+unsubscr...@googlegroups.com.
> >>>> >> For more options, visit https://groups.google.com/d/optout.
> >>>> >
> >>>> >
> >>>> > --
> >>>> > 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
> >>>> > Note that posts from new members are moderated - please be patient
> with
> >>>> > your
> >>>> > first post.
> >>>> > 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
> >>>> > ---
> >>>> > You received this message because you are subscribed to the Google
> >>>> > Groups
> >>>> > "Clojure" group.
> >>>> > To unsubscribe from this group and stop receiving emails from it,
> send
> >>>> > an
> >>>> > email to clojure+unsubscr...@googlegroups.com.
> >>>> > For more options, visit https://groups.google.com/d/optout.
> >>>>
> >>>> --
> >>>> 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
> >>>> Note that posts from new members are moderated - please be patient
> with
> >>>> your first post.
> >>>> 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
> >>>> ---
> >>>> You received this message because you are subscribed to the Google
> Groups
> >>>> "Clojure" group.
> >>>> To unsubscribe from this group and stop receiving emails from it,
> send an
> >>>> email to clojure+unsubscr...@googlegroups.com.
> >>>> For more options, visit https://groups.google.com/d/optout.
> >>>
> >>>
> >>>
> >>>
> >>> --
> >>> "One of the main causes of the fall of the Roman Empire was
> that-lacking
> >>> zero-they had no way to indicate successful termination of their C
> >>> programs."
> >>> (Robert Firth)
> >>>
> >>> --
> >>> 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
> >>> Note that posts from new members are moderated - please be patient
> with your
> >>> first post.
> >>> 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
> >>> ---
> >>> You received this message because you are subscribed to the Google
> Groups
> >>> "Clojure" group.
> >>> To unsubscribe from this group and stop receiving emails from it, send
> an
> >>> email to clojure+unsubscr...@googlegroups.com.
> >>> For more options, visit https://groups.google.com/d/optout.
> >>
> >> --
> >> 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
> >> Note that posts from new members are moderated - please be patient with
> your first post.
> >> 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
> >> ---
> >> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an email to clojure+unsubscr...@googlegroups.com.
> >> For more options, visit https://groups.google.com/d/optout.
> >
> > --
> > 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
> > Note that posts from new members are moderated - please be patient with
> your first post.
> > 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
> > ---
> > You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to clojure+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> 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
> Note that posts from new members are moderated - please be patient with
> your first post.
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
"One of the main causes of the fall of the Roman Empire was that-lacking
zero-they had no way to indicate successful termination of their C
programs."
(Robert Firth)

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to